首页 / 软件开发 / C# / C#中使用HttpWebRequest类调用WEB服务的示例
C#中使用HttpWebRequest类调用WEB服务的示例2011-06-26 博客园 幸福延长线上一篇文章是关于 CMPP3.0 的 C# 实现,我为了测试其中的 PROVISION 接口,利用了 System.Net.HttpWebRequest 类将《MISC系统短信SP接入指南-接口改造分册》文档中的示例 xml 发送到了 WEB 服务,并从 WEB 服务返回了对应的 Resp 包(也是一段 xml),下面就将代码贴出来:1、SyncOrderRelationReq 包的 xml 内容:<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://www.monternet.com/dsmp/schemas/">00110318384464</TransactionID>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<SyncOrderRelationReq xmlns="http://www.monternet.com/dsmp/schemas/">
<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>1</UserIDType>
<MSISDN>13456781234</MSISDN>
<PseudoCode></PseudoCode>
</FeeUser_ID>
<DestUser_ID>
<UserIDType>1</UserIDType>
<MSISDN>13456781234</MSISDN>
<PseudoCode></PseudoCode>
</DestUser_ID>
<LinkID>SP</LinkID>
<ActionID>1</ActionID>
<ActionReasonID>1</ActionReasonID>
<SPID>419000</SPID>
<SPServiceID>-YYXXYYXX</SPServiceID>
<AccessMode>3</AccessMode>
<FeatureStr>MTA2NjIxNDQgREE=</FeatureStr>
</SyncOrderRelationReq>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>