java中用axis调用多入参的webservice出现No such operation 'callWebService'的错误如何解决

zhangqin12356 2011-10-09 10:03:13
java中用axis调用多入参的webservice出现No such operation 'callWebService'的错误如何解决?

在java中调用的入参报文如是:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv=" http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:callWebService soapenv:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1=" http://webservice.bsn.ztesoft.com">
<connectId xsi:type="xsd:string">1</connectId>
<content xsi:type="xsd:string"><?xml version="1.0" encoding="UTF-8"?><AccumulatorQueryReq><AccNbr>18919800951</AccNbr><QryType>1</QryType><FamilyId>10</FamilyId><BeginMonth>2011-09</BeginMonth><EndMonth>2011-09</EndMonth><QueryType>50</QueryType><SysCode></SysCode></AccumulatorQueryReq></content>
<passwd xsi:type="xsd:string">1</passwd>
<srvFunction xsi:type="xsd:string">AccumulatorQuery</srvFunction>
<srvModule xsi:type="xsd:string">AccumulatorQuerySrv</srvModule>
</ns1:callWebService>
</soapenv:Body>
</soapenv:Envelope>

正确的入参报文是:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:m0="http://model.webservice.bsn.ztesoft.com">
<SOAP-ENV:Body>
<m:callWebService xmlns:m="http://webservice.bsn.ztesoft.com" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<requMessage xsi:type="m0:RequMessage">
<connectId xsi:type="xsd:string">1</connectId>
<content xsi:type="xsd:string"><?xml version="1.0" encoding="UTF-8"?><AccumulatorQueryReq><AccNbr>18919800951</AccNbr><QryType>1</QryType><FamilyId>10</FamilyId><BeginMonth>2011-09</BeginMonth><EndMonth>2011-09</EndMonth><QueryType>50</QueryType><SysCode></SysCode></AccumulatorQueryReq>
</content>
<passwd xsi:type="xsd:string">1</passwd>
<srvFunction xsi:type="xsd:string">AccumulatorQuery</srvFunction>
<srvModule xsi:type="xsd:string">AccumulatorQuerySrv</srvModule>
</requMessage>
</m:callWebService>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


比较java中该调用错误的报文和正确的报文,发现错误的原因好像是入参报文中缺少一层节点
<requMessage xsi:type="m0:RequMessage">
...
</requMessage>

现在的问题是:如何在java程序中增加这样的节点呢?还是有其他的错误原因?求高手解答。
...全文
1970 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangqin12356 2011-10-25
  • 打赏
  • 举报
回复
问题已解决,有两种方法:
1、将由wsdl文档生成的客户端代码嵌入到工程项目中,能够实现,但不是很好;
2、用HttpClient来调用,调用如下:
String soapInput ="123";
String url ="http://localhost:8080/test/services/hello";
PostMethod postMethod = new PostMethod(url);
byte[] b = soapInput.getBytes();
InputStream is = new ByteArrayInputStream(b, 0, b.length);
RequestEntity re = new InputStreamRequestEntity(is, b.length,
"text/xml; charset=utf-8");
postMethod.setRequestEntity(re);
HttpClient httpClient = new HttpClient();
try {
int statusCode = httpClient.executeMethod(postMethod);
System.out.println(statusCode);
InputStream inResponse = postMethod.getResponseBodyAsStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inResponse));
StringBuffer buffer = new StringBuffer();
String line = "";
try {
while ((line = reader.readLine()) != null) {
buffer.append(line);
}
} catch (IOException e) {
e.printStackTrace();
}
String soapResponse = buffer.toString();
System.out.println(soapResponse);
} catch (HttpException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
zhangqin12356 2011-10-09
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 trocp 的回复:]
没发布好
[/Quote]

webservice服务发布好了,soapUI调用可以,就是在java中写的调用时出错了。
oO临时工Oo 2011-10-09
  • 打赏
  • 举报
回复
没发布好

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧