0

私は一般的にWebサービスにまったく慣れておらず、IISとWebサービス自体の構成に(私が思うに)行き詰まっています。

MVS 2010 で wcf Web サービスを作成し、Windows 7 の IIS7.5 でホストしました。soapUI 4.5.0 を使用して、Web サービス コントラクトを作成したのと同じ wsdl 記述から生成されたメッセージを投稿します。問題は、http POST が Web サービスまたは Web サーバーでサポートされていないように見えるため、405 が発生することです。

表示されるエラーだけで問題を解決できると思っていたのに、IIS と Web サービスに関する知識が不足しているため、適切な解決策を見つけることができません。

以下、思いつく限りの情報。それが助けになり、誰かが私を正しい方向に導くことができることを願っています.

IIS で行われた構成:

承認規則: 許可、すべてのユーザー

  • ディレクトリの閲覧: 有効
  • ハンドラー マッピング: 機能 パーミッション: 読み取り、スクリプト、および実行
  • ハンドラー マッピング: 追加 *.wsdl -> ProtocolSupportModule -> GET、HEAD、OPTIONS、TRACE、POST
  • アプリケーション プール: .net fw 4.0 を使用して ID NetworkService のエントリを追加

送信されたメッセージは次のとおりです。

RAW: POST http: xxxx:21378/ HTTP/1.1 Accept-Encoding: gzip,deflate Content-Type: application/soap+xml;charset=UTF-8;action="/BootNotification"

XML:

<soap:Envelope xmlns:soap="org/2003/05/soap-envelope" xmlns:ns="urn://Ocpp/Cs/2012/02/">
   <soap:Header/>
   <soap:Body>
      <ns:bootNotificationResponse>
         <ns:status>Accepted</ns:status>
         <ns:currentTime>${now}</ns:currentTime>
         <ns:heartbeatInterval>900</ns:heartbeatInterval>
      </ns:bootNotificationResponse>
   </soap:Body>
</soap:Envelope>

返される結果は次のとおりです。

この投稿のサイズを制限するために切り詰めました。

RAW: HTTP/1.1 405 Method Not Allowed キャッシュ制御: プライベート 許可: GET、HEAD、OPTIONS、TRACE コンテンツ タイプ: text/html; charset=utf-8 サーバー: Microsoft-IIS/7.5 X-Powered-By: ASP.NET 日付: 2012 年 6 月 7 日 (木) 07:58:09 GMT コンテンツの長さ: 5611

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns=".org/1999/xhtml"> 
<head> 
<title>IIS 7.5 Detailed Error - 405.0 - Method Not Allowed</title> 
<style type="text/css"> 

...
...
...

<div class="content-container"> 
 <fieldset><legend>Most likely causes:</legend> 
  <ul>  <li>The request sent to the Web server used an HTTP verb that is not allowed by the module configured to handle the request.</li>   <li>A request was sent to the server that contained an invalid HTTP verb.</li>  <li>The request is for static content and contains an HTTP verb other than GET or HEAD.</li>    <li>A request was sent to a virtual directory using the HTTP verb POST and the default document is a static file that does not support HTTP verbs other than GET or HEAD.</li> </ul> 
 </fieldset> 
</div> 
<div class="content-container"> 
 <fieldset><legend>Things you can try:</legend> 
  <ul>  <li>Verify the list of verbs enabled for the module handler this request was sent to, and ensure that this verb should be allowed for the Web site.</li>    <li>Check the IIS log file to see which verb is not allowed for the request.</li>   <li>Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click <a href=".com/fwlink/?LinkID=66439">here</a>. </li> </ul> 
 </fieldset> 
</div> 


<div class="content-container"> 
 <fieldset><legend>Links and More Information</legend> 
  This error means that the request sent to the Web server contained an HTTP verb that is not allowed by the configured module handler for the request. 
  <p><a href="amp;IIS70Error=405,0,0x80070001,7601">View more information &raquo;</a></p> 

 </fieldset> 
</div> 
</div> 
</body> 
</html> 

XML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ".org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns=".org/1999/xhtml"> 
<head> 
<title>IIS 7.5 Detailed Error - 405.0 - Method Not Allowed</title> 
<style type="text/css"> 

...

</head> 
<body> 
<div id="header"><h1>Server Error in Application "SHENZIWEBSERVICEDEPLOYED"</h1></div> 
<div id="server_version"><p>Internet Information Services 7.5</p></div> 
<div id="content"> 
<div class="content-container"> 
 <fieldset><legend>Error Summary</legend> 
  <h2>HTTP Error 405.0 - Method Not Allowed</h2> 
  <h3>The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.</h3> 
 </fieldset> 
</div> 
<div class="content-container"> 

...

</div> 
<div class="content-container"> 
 <fieldset><legend>Most likely causes:</legend> 
  <ul>  <li>The request sent to the Web server used an HTTP verb that is not allowed by the module configured to handle the request.</li>   <li>A request was sent to the server that contained an invalid HTTP verb.</li>  <li>The request is for static content and contains an HTTP verb other than GET or HEAD.</li>    <li>A request was sent to a virtual directory using the HTTP verb POST and the default document is a static file that does not support HTTP verbs other than GET or HEAD.</li> </ul> 
 </fieldset> 
</div> 
<div class="content-container"> 
 <fieldset><legend>Things you can try:</legend> 
  <ul>  <li>Verify the list of verbs enabled for the module handler this request was sent to, and ensure that this verb should be allowed for the Web site.</li>    <li>Check the IIS log file to see which verb is not allowed for the request.</li>   <li>Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click <a href=".com/fwlink/?LinkID=66439">here</a>. </li> </ul> 
 </fieldset> 
</div> 


<div class="content-container"> 
 <fieldset><legend>Links and More Information</legend> 
  This error means that the request sent to the Web server contained an HTTP verb that is not allowed by the configured module handler for the request. 
  <p><a href=".com/fwlink/?LinkID=62293&amp;IIS70Error=405,0,0x80070001,7601">View more information &raquo;</a></p> 

 </fieldset> 
</div> 
</div> 
</body> 
</html> 

これは、生成されたサービス コントラクトの一部です (wsdl /language:CS /serverInterface

// CODEGEN: The optional WSDL extension element 'PolicyReference' from namespace 'http://schemas.xmlsoap.org/ws/2004/09/policy' was not handled.
[ServiceContract(Name = "CentralSystemServiceSoap", Namespace = "urn://Ocpp/Cs/2010/08/")]
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
[System.Web.Services.WebServiceBindingAttribute(Name="CentralSystemServiceSoap", Namespace="urn://Ocpp/Cs/2010/08/")]
public interface ICentralSystemServiceSoap {
    /// <remarks/>
    [OperationContract]
    [System.Web.Services.Protocols.SoapHeaderAttribute("chargeBoxIdentity")]
    [System.Web.Services.WebMethodAttribute()]
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("/BootNotification", RequestElementName = "bootNotificationRequest", RequestNamespace = "urn://Ocpp/Cs/2010/08/", ResponseElementName = "bootNotificationResponse", ResponseNamespace = "urn://Ocpp/Cs/2010/08/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
    [return: System.Xml.Serialization.XmlElementAttribute("status")]
    RegistrationStatus BootNotification(string chargePointVendor, string chargePointModel, string chargePointSerialNumber, string chargeBoxSerialNumber, string firmwareVersion, string iccid, string imsi, string meterType, string meterSerialNumber, out System.DateTime currentTime, [System.Xml.Serialization.XmlIgnoreAttribute()] out bool currentTimeSpecified, out int heartbeatInterval, [System.Xml.Serialization.XmlIgnoreAttribute()] out bool heartbeatIntervalSpecified);
4

1 に答える 1

1

あなたのサービスがどのように構築され、そこで何をしたかはわかりませんでしたが、私の経験から、これは POST 要求をサポートする wcf RESTful サービスを作成する簡単な方法です。

http://www.codeproject.com/Articles/201901/CREATE-RESTful-WCF-Service-API-Using-POST-Step-By

コメントに従って更新します。

それを使ってみてください:

[OperationContract]
[WebInvoke(Method = "POST")]
[System.Web.Services.Protocols.SoapHeaderAttribute("chargeBoxIdentity")]
[System.Web.Services.WebMethodAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("/BootNotification", RequestElementName = "bootNotificationRequest", RequestNamespace = "urn://Ocpp/Cs/2010/08/", ResponseElementName = "bootNotificationResponse", ResponseNamespace = "urn://Ocpp/Cs/2010/08/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("status")]
RegistrationStatus BootNotification(string chargePointVendor, string chargePointModel, string chargePointSerialNumber, string chargeBoxSerialNumber, string firmwareVersion, string iccid, string imsi, string meterType, string meterSerialNumber, out System.DateTime currentTime, [System.Xml.Serialization.XmlIgnoreAttribute()] out bool currentTimeSpecified, out int heartbeatInterval, [System.Xml.Serialization.XmlIgnoreAttribute()] out bool heartbeatIntervalSpecified);

アップデート

それをやってみてください:

IIS 7.5 の場合 -> YourWebsite -> Handler Mappings

パネルの右側にある [モジュール マッピングの追加] オプションを選択します。

「リクエストパス」フィールドに *.wsdl と入力します

「モジュール」フィールドに「ProtocolSupportModule」と入力します

「リクエスト制限」をクリックし、動詞タブに移動します

POST動詞を入力してください

変更内容を保存

于 2012-06-07T11:25:15.993 に答える