WebService用Axis2编写客户端调用报错[The given SOAPAction urn:anon

J2EE 码拜 8年前 (2017-04-18) 4265次浏览
第一次接触WebService,别人提供的WebService接口,本人试着用Java编写的客户端去调用服务。
结果卡在下面报错的地方了。网上也查看了很多相似的错误,但是还是无法解决,所以求帮助各位高手了。
错误信息:
信息: Deploying module: addressing-1.3
org.apache.axis2.AxisFault: The given SOAPAction urn:anonOutInOp does not match an operation.
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:486)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:343)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:389)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:528)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:508)
at test.Test.queryMessageFile(Test.java:157)
at test.Test.main(Test.java:44)
WSDL内容:
WebService用Axis2编写客户端调用报错[The given SOAPAction urn:anon
WebService用Axis2编写客户端调用报错[The given SOAPAction urn:anon
客户端代码:

        OMFactory fac = OMAbstractFactory.getOMFactory();
        // 命名空间
        OMNamespace omNs = fac.createOMNamespace("http://webservice.creditreport.p2p.sino.com/", "");
        // 调用的WebService方法
        OMElement ome = fac.createOMElement("queryBatchCreditFile", omNs);
        
        // 参数1设定
        OMElement omeOrgcode = fac.createOMElement("orgcode", omNs);
        omeOrgcode.setText(orgcode);
        
        // 参数2设定
        OMElement omeSecret = fac.createOMElement("secret", omNs);
        omeSecret.setText(secret);
        
        // 参数3设定
        OMElement omeFilename=fac.createOMElement("filename", omNs);
        // 文件名取得
        String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
        omeFilename.setText(fileName);
        ome.addChild(omeOrgcode);
        ome.addChild(omeSecret);
        ome.addChild(omeFilename);
        Options options = new Options();
        EndpointReference targetEPR = new EndpointReference(targetAddr);
        options.setTo(targetEPR);
        // 设定调用方法名
        options.setAction("");
        // Cookie设定
        StringBuffer cookieSb = new StringBuffer();
        options.setManageSession(true);
        cookieSb.append("Set-Cookie:");
        for(Cookie cookie:cookies) {
            cookieSb.append(cookie);
            cookieSb.append(";");
        }
        options.setProperty(HTTPConstants.COOKIE_STRING, cookieSb.toString());
        
        // 禁用HTTP传输分段特性,避免报错
        options.setProperty(HTTPConstants.CHUNKED, false);
        ServiceClient sc = new ServiceClient();
        sc.setOptions(options);
        // 调用方法
        OMElement out = sc.sendReceive(ome);
        String outStr = out.getText();
        System.out.println(outStr);
解决方案

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明WebService用Axis2编写客户端调用报错[The given SOAPAction urn:anon
喜欢 (0)
[1034331897@qq.com]
分享 (0)