日期:2014-05-17  浏览次数:20744 次

axis调用dot net webservice传参为null的问题
在利用axis调用dot net webservice的时候发现权限验证通过了,但是客户端传到服务端的参数却是null,求解。
		String endpointURL = "http://.../Service.asmx";
try
{
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpointURL));
call.setSOAPActionURI("http://tempuri.org/QueryData");
call.setOperationName(new QName("http://tempuri.org/", "QueryData"));

call.addParameter(new QName("http://tempuri.org/","xmlData"),XMLType.XSD_STRING, ParameterMode.IN);// 参数的类型
call.setReturnType(XMLType.XSD_STRING);// 返回的数据类型

SOAPHeaderElement soapHeaderElement = new SOAPHeaderElement("http://tempuri.org/", "AuthorizationSoapHeader");
soapHeaderElement.setNamespaceURI("http://tempuri.org/");
try
{
soapHeaderElement.addChildElement("UserName").setValue("username");
soapHeaderElement.addChildElement("Password").setValue("password");
}
catch (SOAPException e)
{
e.printStackTrace();
}
call.addHeader(soapHeaderElement);
call.setUseSOAPAction(true); 
String ret = (String) call.invoke(new Object[]{new String("<root><parameters><serviceID>Q0203001</serviceID></parameters><root>".getBytes("UTF-8"), "GB2312")});// 执行调用
System.out.println(ret);
}
catch (Exception e)
{
e.printStackTrace();
}

------解决方案--------------------
接口是双方的事情,兴许问题出在对方,曾经用JAVA调用.NET的接口出现类似问题,对方好像是命名空间有问题所以一直报错。。。