java用SOAP调用WEB SERVICE的问题,帮忙看看,已经郁闷好几天了(100分)

  • 主题发起人 主题发起人 xx0118
  • 开始时间 开始时间
X

xx0118

Unregistered / Unconfirmed
GUEST, unregistred user!
Call call = new Call();
// 创建类型映射注册器
SOAPMappingRegistry smr = new SOAPMappingRegistry();
BeanSerializer beanSer = new BeanSerializer();
// 映射类型
smr.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("http://service.zx.chinavnet.com/v1.0/Logout","Logout"),null, beanSer, beanSer);
call.setSOAPMappingRegistry(smr);
call.setTargetObjectURI("http://service.zx.chinavnet.com/v1.0/Logout");
call.setMethodName("Logout");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
Vector params = new Vector();
params.addElement (new Parameter("SenderID", String.class, "111", Constants.NS_URI_SOAP_ENC));
params.addElement (new Parameter("SPID", String.class, "111", Constants.NS_URI_SOAP_ENC));
params.addElement (new Parameter("TimeStamp", String.class, "111", Constants.NS_URI_SOAP_ENC));
params.addElement (new Parameter("UserID", String.class, "111", Constants.NS_URI_SOAP_ENC));
params.addElement (new Parameter("NickName", String.class, "111", Constants.NS_URI_SOAP_ENC));
call.setParams(params);
Response resp = null;
try {
resp = call.invoke(url, "http://service.zx.chinavnet.com/v1.0/Logout");//在这调用失败
}
catch (SOAPException e) {
System.err.println("Caught SOAPException (" + e.getFaultCode () + "): " + e.getMessage ());
//调用失败,提示:Caught SOAPException (SOAP-ENV:Client): No Deserializer found to deserialize a 'http://service.zx.chinavnet.com/v1.0/:LogoutResult' using encoding style 'null'.
return;
}
// 检查返回值
if (resp != null &&
!resp.generatedFault()) {
System.out.println ("invoke succufll!");
}
else
{
Fault fault = resp.getFault ();
System.err.println ("Generated fault: ");
System.out.println (" Fault Code = " + fault.getFaultCode());
System.out.println (" Fault String = " + fault.getFaultString());
}
resp = call.invoke(url, "http://service.zx.chinavnet.com/v1.0/Logout");//在这调用失败
//调用失败,提示:Caught SOAPException (SOAP-ENV:Client): No Deserializer found to deserialize a 'http://service.zx.chinavnet.com/v1.0/:LogoutResult' using encoding style 'null'.
url为:http://developer.chinavnet.com/VNetInterface/SPForVNet/SPInterfaceForVNet.asmx
大家可以在线试试看
 
应该是你的调用的编码部队,不能正确解析返回的文本。试试这样的处理
call.setEncodingStyleURI ("http://schemas.xmlsoap.org/soap/encoding/");
参考这篇文章
http://www.csharphelp.com/archives/archive53.html
 
后退
顶部