首页 > 代码库 > Webservice调用服务端 Unmarshalling Error: unexpected element (Xxx). Expected elements are Xxx

Webservice调用服务端 Unmarshalling Error: unexpected element (Xxx). Expected elements are Xxx

使用Axis2调用CXF服务端Webservice方法时:

报错:Unmarshalling Error: unexpected element (uri:"http://ejb.fss.keyman.com", local:"xmldata"). Expected elements are <{}arg0>

详细信息如下:

org.apache.axis2.AxisFault: Unmarshalling Error: unexpected element (uri:"http://ejb.fss.keyman.com", local:"xmldata"). Expected elements are <{}arg0>
    at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
    at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
    at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:555)
    at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:531)
    at com.keyman.fss.test.FindResultByWorkIDTest.ReportResult(FindResultByWorkIDTest.java:69)
    at com.keyman.fss.test.FindResultByWorkIDTest.main(FindResultByWorkIDTest.java:80)


解决办法:

在Webservice服务端方法参数前面加上,@WebParam(name = "xmldata", targetNamespace = "http://ejb.fss.keyman.com")

命令空间之类的信息。

例子如下:

	public String findResultByWorkID(@WebParam(name = "xmldata", targetNamespace = "http://ejb.fss.keyman.com") String xmldata) {
	
		具体代码
	}


Webservice调用服务端 Unmarshalling Error: unexpected element (Xxx). Expected elements are Xxx