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">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;AccumulatorQueryReq&gt;&lt;AccNbr&gt;18919800951&lt;/AccNbr&gt;&lt;QryType&gt;1&lt;/QryType&gt;&lt;FamilyId&gt;10&lt;/FamilyId&gt;&lt;BeginMonth&gt;2011-09&lt;/BeginMonth&gt;&lt;EndMonth&gt;2011-09&lt;/EndMonth&gt;&lt;QueryType&gt;50&lt;/QueryType&gt;&lt;SysCode&gt;&lt;/SysCode&gt;&lt;/AccumulatorQueryReq&gt;</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">&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;AccumulatorQueryReq&gt;&lt;AccNbr&gt;18919800951&lt;/AccNbr&gt;&lt;QryType&gt;1&lt;/QryType&gt;&lt;FamilyId&gt;10&lt;/FamilyId&gt;&lt;BeginMonth&gt;2011-09&lt;/BeginMonth&gt;&lt;EndMonth&gt;2011-09&lt;/EndMonth&gt;&lt;QueryType&gt;50&lt;/QueryType&gt;&lt;SysCode&gt;&lt;/SysCode&gt;&lt;/AccumulatorQueryReq&gt;
</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程序中增加这样的节点呢?还是有其他的错误原因?求高手解答。

解决方案 »

  1.   


    webservice服务发布好了,soapUI调用可以,就是在java中写的调用时出错了。
      

  2.   

    问题已解决,有两种方法:
    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();
    }