.net WebService接口参数为实体类数组,java调用接口怎么把参数转换成string类型的xml内容 80
比如,.net接口为publicMassgeReturnSendPackage(Package[]packages,stringusrName){},用java调用该接口...
比如,.net 接口为public MassgeReturn SendPackage(Package[] packages,string usrName){},用java调用该接口,如果要将参数直接转成xml格式的string,那么xml的格式应该是怎么样的?例如:
string xml="<List_Package<UnSend_Package<PACKAGE_ID>L06000A45052774</PACKAGE_ID><PACKAGE_SHOW_ID></UnSend_Package></List_Package>";
String soapAction = "http://tempuri.org/UrgentSend";
// 指定WebService的命名空间和调用的方法名
SoapObject rpc = new SoapObject(nameSpace, methodName);
PropertyInfo info=new PropertyInfo();
info.setName("StringValue");
info.setValue(packagesXML);//转换为string的xml格式字符串
rpc.addProperty(info);
// 生成调用WebService方法的SOAP请求信息,并指定SOAP的版本
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
// 设置是否调用的是dotNet开发的WebService
envelope.dotNet = true;
//(new MarshalBase64()).register(envelope);
// 等价于envelope.bodyOut = rpc;
envelope.setOutputSoapObject(rpc);
HttpTransportSE transport = new HttpTransportSE(endPoint);
transport.debug = false; 展开
string xml="<List_Package<UnSend_Package<PACKAGE_ID>L06000A45052774</PACKAGE_ID><PACKAGE_SHOW_ID></UnSend_Package></List_Package>";
String soapAction = "http://tempuri.org/UrgentSend";
// 指定WebService的命名空间和调用的方法名
SoapObject rpc = new SoapObject(nameSpace, methodName);
PropertyInfo info=new PropertyInfo();
info.setName("StringValue");
info.setValue(packagesXML);//转换为string的xml格式字符串
rpc.addProperty(info);
// 生成调用WebService方法的SOAP请求信息,并指定SOAP的版本
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
// 设置是否调用的是dotNet开发的WebService
envelope.dotNet = true;
//(new MarshalBase64()).register(envelope);
// 等价于envelope.bodyOut = rpc;
envelope.setOutputSoapObject(rpc);
HttpTransportSE transport = new HttpTransportSE(endPoint);
transport.debug = false; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询