axis2调用ws异常

cjjimmery 2013-08-22 04:36:52
服务端wsdl为:
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions name="WebServiceBeanService" targetNamespace="http://isag.webservice.iface.app.fsti.com/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://isag.webservice.iface.app.fsti.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <wsdl:types>
- <xs:schema elementFormDefault="unqualified" targetNamespace="http://isag.webservice.iface.app.fsti.com/" version="1.0" xmlns:tns="http://isag.webservice.iface.app.fsti.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="doWebKpi" type="tns:doWebKpi" />
<xs:element name="doWebKpiResponse" type="tns:doWebKpiResponse" />
- <xs:complexType name="doWebKpi">
- <xs:sequence>
<xs:element minOccurs="0" name="xmlKpi" type="xs:string" />
</xs:sequence>
</xs:complexType>
- <xs:complexType name="doWebKpiResponse">
- <xs:sequence>
<xs:element name="return" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
- <wsdl:message name="doWebKpiResponse">
<wsdl:part element="tns:doWebKpiResponse" name="parameters" />
</wsdl:message>
- <wsdl:message name="doWebKpi">
<wsdl:part element="tns:doWebKpi" name="parameters" />
</wsdl:message>
- <wsdl:portType name="WebServiceIface">
- <wsdl:operation name="doWebKpi">
<wsdl:input message="tns:doWebKpi" name="doWebKpi" />
<wsdl:output message="tns:doWebKpiResponse" name="doWebKpiResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="WebServiceBeanServiceSoapBinding" type="tns:WebServiceIface">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="doWebKpi">
<soap:operation soapAction="" style="document" />
- <wsdl:input name="doWebKpi">
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output name="doWebKpiResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="WebServiceBeanService">
- <wsdl:port binding="tns:WebServiceBeanServiceSoapBinding" name="WebServiceBeanPort">
<soap:address location="http://xxx.xxx.xxx.xxx:8080/isag-web-service/WebServiceBean" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>


客户端调用:

String url = "http://xxx.xxx.xxx.xxx:8080/isag-web-service/WebServiceBean"; // wsdl文件地址
String nameSpace = "http://isag.webservice.iface.app.fsti.com/";
String methodName = "doWebKpi";// WSDL里面描述的接口名称

LinkedHashMap<String,String> params = new LinkedHashMap<String, String>();
params.put("xmlKpi", "xx");
WebServiceUtil webServiceUtil = new WebServiceUtil();
OMElement results= webServiceUtil.webservice4document(url, nameSpace, methodName, params);



package com.fsti.app.iface.webservice.isag;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;

public class WebServiceUtil {
/**
*
* endpoint:wsdl地址 namespace:wsdl命名空间 methodname:接口方法名 params:参数
* @date Apr 10, 2013 9:25:29 AM
*/
public static OMElement webservice4document(String url,String namespace,String methodname,LinkedHashMap params) throws AxisFault{
EndpointReference targetEPR = new EndpointReference(url);
Options options = new Options();
options.setTo(targetEPR);


ServiceClient sender = new ServiceClient();
sender.setOptions(options);
OMFactory fac = OMAbstractFactory.getOMFactory();
/* 命名空间*/
OMNamespace omNs = fac.createOMNamespace(namespace, "");
OMElement method = fac.createOMElement(methodname, omNs);
if (params!=null) {
Iterator iterator = params.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry) iterator.next();
OMElement param = fac.createOMElement(entry.getKey().toString(), omNs);
param.addChild(fac.createOMText(param,entry.getValue().toString()));
method.addChild(param);
}
method.build();
OMElement results = sender.sendReceive(method);
return results;
}else {
return null;
}
}

}

在标红的地方报了如下的异常,请指教
org.apache.axis2.AxisFault: Unmarshalling Error: unexpected element (uri:"http://isag.webservice.iface.app.fsti.com/", local:"xmlKpi"). Expected elements are <{}xmlKpi>

...全文
61 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

50,530

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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