webservice的客户端动态远程调用,报异常:java.lang.IllegalArgumentException: Part {http://****}sendSmsRequest should be of type *.*.*SendSmsRequest, not java.lang.String
具体代码:
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance(); Client client1 = factory.createClient("http://***?wsdl"); //处理 WebService接口和实现类namespace不同的情况// CXF动态客户端在处理此问题时,会报No operation was found with the name的异常 Endpoint endpoint = client1.getEndpoint(); String operation="sendSms"; QName opName = new QName(endpoint.getService().getName().getNamespaceURI(), operation); BindingInfo bindingInfo = endpoint.getEndpointInfo().getBinding(); if (bindingInfo.getOperation(opName) == null) { for (BindingOperationInfo operationInfo : bindingInfo.getOperations()) { if (operation.equals(operationInfo.getName().getLocalPart())) { opName = operationInfo.getName(); break; } } } Object[] objects1 = null; // String jsonString= try { objects1 = client1.invoke(opName, "**", "**", "**", "", "**"); } catch (Exception e) { e.printStackTrace(); }
wsdl:
<element name="sendSmsRequest">
<complexType>
<sequence>
<element name="*" nillable="true" type="xsd:string"/>
<element maxOccurs="unbounded" minOccurs="0" name="*" nillable="true" type="xsd:anyURI"/>
<element name="*" nillable="true" type="xsd:string"/>
<element name="*" nillable="true" type="xsd:string"/>
<element name="*" nillable="true" type="tns4:MessageFormat"/>
<element name="*" nillable="true" type="tns4:SendMethodType"/>
<element name="*" type="xsd:boolean"/>
</sequence>
</complexType>
</element>
麻烦帮忙查看