最近工作中有用到Axis,java调用.net写的webservice,先将调用过程中所遇到的问题罗列如下:
1: faultString: System.Web.Services.Protocols.soapException: 服务器未能识别 HTTP 头 SOAPAction 的值: 。
这个异常的解决办法:
call.setSOAPActionURI(namespace+functionName);
需要Axis调用端的方法参数名称和.net所写的方法的参数名称一致,否则就会报告这个错误.
public void testWgt2() throws Exception{ //.net webService 地址 String url="url"; //.net webService 命名空间 String namespace = "namespace"; //.net webService 需调用的方法 String methodName = "method"; Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL(url)); call.setUseSOAPAction(true); call.setoperationName(new QName(namespace,methodName)); call.addParameter( new QName(namespace,"username"), org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.addParameter( new QName(namespace,"password"), org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.setReturnType(XMLType.XSD_STRING); call.setSOAPActionURI(namespace+methodName); String ret = (String) call.invoke(new String[]{"xxx",""}); System.out.println("返回结果---> " + ret); }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。