我需要调用另外一个厂商的webservice接口,在soapUI工具中调用成功,请求格式如下:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.business.sms.star.com">
<soapenv:Header>
<USERNAME xmlns="NAMESPACE">me</VOD_USERNAME>
<PASSWORD xmlns="NAMESPACE">pass</VOD_PASSWORD>
<VERSION xmlns="NAMESPACE">1.5</VOD_VERSION>
</soapenv:Header>
<soapenv:Body>
...
</soapenv:Body>
</soapenv:Envelope>
想问一下,我用xfire框架如何将<soapenv:Header>里的内容发送给服务端?
我一开始用axis1,但调用后老出现错误:Premature end of file,后为改用了xfire框架。
<?xml version= '1.0 ' encoding= 'utf-8 '?>
<SOAP-ENV:Envelope xmlns:xsi= 'http://www.w3.org/2001/XMLSchema-instance '
xmlns:xsd= 'http://www.w3.org/2001/XMLSchema '
xmlns:SOAP-ENV= 'http://schemas.xmlsoap.org/soap/envelope/ '
xmlns:SOAP-ENC= 'http://schemas.xmlsoap.org/soap/encoding/ '>
<SOAP-ENV:Header>
<TransactionID xmlns= 'http://10.1.2.122/misc/dsmp.xsd '> 00110100037392 </TransactionID>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<SyncOrderRelationReq xmlns= 'http://10.1.2.122/misc/dsmp.xsd '>
<Version> 1.5.0 </Version>
<MsgType> SyncOrderRelationReq </MsgType>
<Send_Address>
<DeviceType> 0 </DeviceType>
<DeviceID> 0011 </DeviceID>
</Send_Address>
<Dest_Address>
<DeviceType> 400 </DeviceType>
<DeviceID> 0 </DeviceID>
</Dest_Address>
<FeeUser_ID>
<UserIDType> 2 </UserIDType>
<MSISDN> </MSISDN>
<PseudoCode> 00116000000286 </PseudoCode>
</FeeUser_ID>
<DestUser_ID>
<UserIDType> 2 </UserIDType>
<MSISDN> </MSISDN>
<PseudoCode> 00116000000286 </PseudoCode>
</DestUser_ID>
<LinkID> SP </LinkID>
<ActionID> 1 </ActionID>
<ActionReasonID> 1 </ActionReasonID>
<SPID> 900562 </SPID>
<SPServiceID> 04101040 </SPServiceID>
<AccessMode> 5 </AccessMode>
<FeatureStr> </FeatureStr>
</SyncOrderRelationReq>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
如何能够得到TransactionID 的值 00110100037392
SAXBuilder builder = new SAXBuilder();
Document doc = null;
StringReader sr = new StringReader(soaptext);
doc = builder.build(sr);
Namespace senv = Namespace.getNamespace( "SOAP-ENV ", "http://schemas.xmlsoap.org/soap/envelope/ ");
Namespace trns = Namespace.getNamespace( "http://10.1.2.122/misc/dsmp.xsd ");
Element root = doc.getRootElement();
Element head = root.getChild( "Header ", senv); // <SOAP-ENV:Header>
Element tid = head.getChild( "TransactionID ", trns); //TransactionID
tidtext = tid.getText();
转soap
猜你喜欢
转载自yizhichao116.iteye.com/blog/1248947
今日推荐
周排行