最近在執行一支程式的時候

因為裡面有呼叫Web Service

結果莫名奇妙的出現了錯誤訊息.....

可是我不久前才執行過都很正常沒有問題.....

真是有點不太懂......

2010112401.jpg

結果Google了一下

這個錯誤出現於當server(或proxy server)無法辨識client送出的Expect標頭

解決方法可以在Web.config的<configuration>區段中加入以下設定

<system.net>
        <settings>
            <servicePointManager expect100Continue="false" />
        </settings>
</system.net>

或是在呼叫Web Service之前加上這一段

System.Net.ServicePointManager.Expect100Continue = false;

這樣就可以正常執行了

參考:

http://social.msdn.microsoft.com/Forums/en-US/devdocs/thread/60cd6e6a-4157-4811-8ed3-1e46f9022ea8

http://www.dotblogs.com.tw/petedotnet/archive/2010/10/09/http417expectationfailedwhencallingwebservice.aspx

http://www.cnblogs.com/yukaizhao/archive/2009/07/15/httpwebrequest_return_417_expectation_failed.html

http://tools.ietf.org/html/rfc2616#section-

arrow
arrow
    全站熱搜

    鴨爸 發表在 痞客邦 留言(0) 人氣()