<text>SOAP_VERSIONMISMATCH</text>
已經解決,主要是檢視了網上的一個同學的帖子,非常感謝。
再來看一下請求資訊
2 Content-Type: multipart/related; boundary="==part20111027095621=="; type="text/xml"; start="<SOAP-ENV:Envelope>"
3 SOAPAction: ""
4 Host: 118.85.200.55:9081
5 Content-Length: 49878
6 Expect: 100-continue
這個是HttpWebRequest 請求的頭。這兩個東西很重要。
Content-Type: multipart/related; boundary="==part20111027095621=="; type="text/xml"; start="<SOAP-ENV:Envelope>"
SOAPAction: "" 電信文件裡有提到,SOAPAction用空值。
需要新增到頭中去。
2 myRequest.ContentType = "multipart/related; boundary=\"==part20111027095621==\"; type=\"text/xml\"; start=\"<SOAP-ENV:Envelope>\"";
3 myRequest.Headers.Add("SOAPAction: \"\"");
接下來就是拼接彩信包了。[求救]電信彩信閘道器開發錯誤-SOAP_VERSIONMISMATCH 文章中的包還是有點小問題,下面看這個成功測試過的包。
2 Host:118.85.200.55:9081
3 User-Agent: WU
4 Content-Type: multipart/related; boundary="==part20120120111818=="; type="text/xml"; start="<BB724A5ADD3D2A96CA5E4697BAD1F3A8>"
5 Content-Length:1803
6 SOAPAction: ""
7
8 --==part20120120111818==
9 Content-Type: text/xml; charset=UTF-8
10 Content-Transfer-Encoding: binary
11 Content-ID: <BB724A5ADD3D2A96CA5E4697BAD1F3A8>
12
13 <?xml version="1.0" encoding="UTF-8"?>
14 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns3="http://www.chinatelecom.com.cn/schema/ctcc/common/v2_1" xmlns:ns1="http://www.chinatelecom.com.cn/schema/ctcc/multimedia_messaging/send/v2_2/local">
15 <SOAP-ENV:Header>
16 <ns3:RequestSOAPHeader>
17 <spId>35101051</spId>
18 <spPassword>E6E19093A2691F495D27332B9F1584F8</spPassword>
19 <timeStamp>0120111818</timeStamp>
20 <productId>135000000000000166819</productId>
21 <SAN></SAN>
22 <transactionId></transactionId>
23 <transEnd>0</transEnd>
24 <linkId>01130545065586044505</linkId>
25 <OA>tel:18925280633</OA>
26 <FA></FA>
27 <multicastMessaging>false</multicastMessaging>
28 </ns3:RequestSOAPHeader>
29 </SOAP-ENV:Header>
30 <SOAP-ENV:Body>
31 <ns1:sendMessage>
32 <ns1:addresses>tel:18925280633</ns1:addresses>
33 <ns1:senderAddress>10660502</ns1:senderAddress>
34 <ns1:subject>生活幫</ns1:subject>
35 <ns1:priority>Default</ns1:priority>
36 <ns1:charging>
37 <description></description>
38 <currency></currency>
39 <amount>100</amount>
40 <code>shb</code>
41 </ns1:charging>
42 <ns1:receiptRequest>
43 <endpoint>tel:18925280633</endpoint>
44 <interfaceName>sendMessage</interfaceName>
45 <correlator>201201130605570433620518925280633</correlator>
46 </ns1:receiptRequest>
47 </ns1:sendMessage>
48 </SOAP-ENV:Body>
49 </SOAP-ENV:Envelope>
50 --==part20120120111818==
51 Content-Type: text/plain; charset=UTF-8
52 Content-Transfer-Encoding: binary
53 Content-ID: <1.txt>
54 Content-Location: 1.txt
55
56 yyadsf
57
58 --==part20120120111818==--
這裡要說的是幾個特別需要注意的地方。
根據包格式組包成功後,和電信對接測試。
一直不能成功。通過抓包發現錯誤提示是
<faultstring>500 Internal Server Error</faultstring>
具體錯誤是:
2 <text>SOAP_VERSIONMISMATCH</text>
繼續和電信提供的包格式核對,確定包體和附件都沒問題。
2 Content-Type: text/xml; charset=UTF-8 這裡有個\r\n
3 Content-Transfer-Encoding: binary 這裡有個\r\n
4 Content-ID: <SOAP-ENV:Envelope> 這裡有個\r\n 還需要在來一個\r\n空一行
5
6 <?xml version="1.0" encoding="UTF-8" ?>
根據包格式組包成功後,和電信對接測試,一直不能成功。
包體和附件,附件中協議和附件體具體格式請參照上面成功的包。
這個換行一定要注意,不然post就不能成功。
返回的資料格式為:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:comm3="http://www.chinatelecom.com.cn/schema/ctcc/common/v2_1" xmlns:mm1="http://www.chinatelecom.com.cn/schema/ctcc/multimedia_messaging/send/v2_2/local">
<SOAP-ENV:Header>
<comm3:NotifySOAPHeader>
<spRevId>szsxd</spRevId>
<spRevpassword>123542</spRevpassword>
<spId>35101051</spId>
<linkId>01130545065586044505</linkId>
</comm3:NotifySOAPHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<mm1:sendMessageResponse>
<mm1:result>19350101400120111824000490H</mm1:result>
</mm1:sendMessageResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
程式處理Ok,再此還要感謝Google的搜尋,和那位大哥的換行指導。