0

私はC#で構築されたasp.net Webアプリケーションに取り組んでいます。PHP を使用して作成されたサード パーティの Web サービスを実装する必要があります。機能は1つだけの非常にシンプルなサービスです。wsdlを使用してサービス参照を追加しましたが、これまでのところうまくいきました。

正しいパラメーターを使用して Web サービス関数を呼び出すと、常に null が返されます。SoapUI でトラブルシューティングを開始しました。アプリケーションから SOAP メッセージを取得し、SoapUI に貼り付けて実行すると、正しいメッセージが返されました。Fiddler を使用すると、生の出力に示されているように、Web サービスからの応答に奇妙なものが見つかりました。

HTTP/1.1 200 OK
Date: Wed, 21 Nov 2012 15:24:31 GMT
Server: Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/0.9.8o
X-Powered-By: PHP/5.2.13-pl1-gentoo
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: PHPSESSID=ddc342cfe7e56e77456fe31b758bf3de; path=/
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Length: 812
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/xml; charset=utf-8

?????????KS?0???`r?~?<???   ?I
I?????0??+?.????kK.????[E?????[???????}??g4
?1J???~w?i??<?M?+w??[>]ziIc???.?
???yvi?"x?  F??d?Y?aR,4?X?
[UQ^F)?$`?
7??[?F"?$??h???S?a??4??Q?E??6Td,t6%Hg??w/)??????]??G*   ?l[??&6?0?$??>??????~?????:??6??W#?a????E?G?
s??Z????§o?_??c??\???-???)?????cc??w???/??f??}?)??r???????T?/???    m??K??8?    ?X?/F8?<???:?m???&f ?Z#[31?*?X,c?Z??0h"??aFb.?<??p??a???Q?B?r>????Z??5??6???????n\y?d?.??\??Hc]??
Z,?x??l???g?Q?*&???1?)??????^?????v??pQ???_y~??%??????*?
>???;??6?+?>???RQq?????a?(?Z????C?5???G??Ce??H?9??xYL|"??i?
e8?Vk???s???AK^?e~??
??(??Lt???r???vs????7??d?w???Jj-B????pt????c??MBi?s)Mo?.??^?aB3?x8&??:_K|???5???)[?M?Xc?j?zX?=G?i/??TO???g????5??c0??w???T??

ヘッダーが正しく表示されます。応答はエンコードされており、デコードする必要があります。SoapUI と Fiddler はどちらも応答をデコードできますが、プロキシ クラスはデコードできず、null を返します。

どうすればこの問題を克服できますか? どんな助けでも大歓迎です!

編集:

サービスの呼び出し方法:

LisenceServiceFR.ServiceRegistration_PortTypeClient client = new LisenceServiceFR.ServiceRegistration_PortTypeClient();
LisenceServiceFR.aVehicleInfo info = client.getVehicleInfo("xxx", "xxx", licensePlate, "localhost");

編集2:

Fiddler からの応答 XML。

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://services.audaconfr.com/ServiceRegistration.wsdl">
    <SOAP-ENV:Body>
        <SOAP-ENV:getVehicleInfoResponse>
            <aVehicle>
                <ns1:errorCode>200</ns1:errorCode>
                <ns1:errorMessage>Success</ns1:errorMessage>
                <ns1:vehicleXml>
            &lt;vehicule&gt;
                &lt;carr&gt;MONOSPACE COMPACT&lt;/carr&gt;
                &lt;carr_cg&gt;CI&lt;/carr_cg&gt;
                &lt;co2&gt;152&lt;/co2&gt;
                <!-- etc -->
            &lt;/vehicule&gt;
        </ns1:vehicleXml>
            </aVehicle>
        </SOAP-ENV:getVehicleInfoResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
4

1 に答える 1

0

最終的に HttpWebRequest を使用して Web サービスを呼び出しました。

System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.InnerXml = xml;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(endPoint);
req.Timeout = 100000000;

if (proxy != null)
    req.Proxy = new WebProxy(proxy, true);

req.Headers.Add("SOAPAction", "");
req.ContentType = "application/soap+xml;charset=\"utf-8\"";
req.Accept = "application/x-www-form-urlencoded"; 
req.Method = "POST";
Stream stm = req.GetRequestStream();
doc.Save(stm);
stm.Close();
WebResponse resp = req.GetResponse();
stm = resp.GetResponseStream();
StreamReader r = new StreamReader(stm);
string responseData = r.ReadToEnd();

XDocument response = XDocument.Parse(responseData);

/* extract data from response */

それは私が探していた解決策ではありませんでしたが、魅力のように機能します.

于 2012-11-27T15:16:44.643 に答える