【发布时间】:2012-01-26 20:31:28
【问题描述】:
我写了一个java SOAP WebService。还有一个消费者。如果我将 SOAP 消息发送到没有参数的方法。一切正常,收到了正确的响应。
但是,我无法使用具有参数的方法。我的 SOAP 消息以下列模式存储在以下字符串中。
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
"<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\">"+
"<S:Header/>"+
"<S:Body>"+
"<ns2:addPerson xmlns:ns2=\"http://service.cass.com/\">"+
"<fName xsi:type=\"xsd:string\">vbn</fName>"+
"<lName xsi:type=\"xsd:string\">yyyy</lName>"+
"<gender xsi:type=\"xsd:string\">879</gender>"+
"<age xsi:type=\"xsd:int\">90</age>"+
"</ns2:addPerson>"+
"</S:Body>"+
"</S:Envelope>";
方法原型是: public boolean addPerson(String fName, String lName, String gender, int age);
我得到以下异常。
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/ServerSide/ws/personService
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1305)
at com.cass.testRequest.makeSOAPRequest(testRequest.java:71)
at com.cass.testRequest.main(testRequest.java:37)
请注意,如果我发送一个不带参数的 SOAPMessage,对于一个带 0 个参数的方法。一切正常,我得到了正确的回应。在我看来,我在 SOAPMessage 中传递参数的方式有问题。请建议如何做到这一点。
问候, 阿奇夫
【问题讨论】:
标签: java web-services soap