急~~~求解soap 问题~
public class SampleCode {
/** Creates a new instance of SampleCode */
public SampleCode() {
}
public static void main(String []vs) {
URL url = null;
try {
url = new URL("http://127.0.0.1/services/test?wsdl");
} catch (MalformedURLException e1) {
e1.printStackTrace();
}
if(null==url){
System.out.println("___________service地址错误");
return ;
}
SOAPMappingRegistry smr = new SOAPMappingRegistry();
StringDeserializer sd = new StringDeserializer();
smr.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("", "Result"), null, null, sd);
// 创建传输路径和参数
SOAPHTTPConnection st = new SOAPHTTPConnection();
// 创建调用
Call call = new Call();
call.setSOAPTransport(st);
call.setSOAPMappingRegistry(smr);
call.setTargetObjectURI("http://127.0.0.1/services/test");
call.setMethodName("webServicesTest");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
Response resp = null;
try {
resp = call.invoke(url, "");
}catch (SOAPException e) {
System.err.println("Caught SOAPException (" + e.getFaultCode() + "): " + e.getMessage());
System.out.println(e.toString());
return ;
}
// 检查返回值
if (resp != null && !resp.generatedFault()){
Parameter ret = resp.getReturnValue();
Object value = ret.getValue();
System.out.println("Answer-----> " + value);
return ;
}else{
Fault fault = resp.getFault();
System.err.println("Generated fault: ");
System.out.println(" Fault Code = " + fault.getFaultCode());
System.out.println(" Fault String = " + fault.getFaultString());
return ;
}
}
}
运行后报错:
[SOAPException: faultCode=SOAP-ENV:Client; msg=No Deserializer found to deserialize a 'http://schemas.xmlsoap.org/soap/encoding/:string' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'.; targetException=java.lang.IllegalArgumentException: No Deserializer found to deserialize a 'http://schemas.xmlsoap.org/soap/encoding/:string' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'.]
如何解决?
报的是string的反序列化问题???还是其它问题啊~~