0

POST 呼び出しを実行できるように、同じコントラクトとサービスを basicHttpBinding と webHttpBinding の両方として公開することを望んでいます。どういうわけか、wsdl を見ると、webHttpBinding のエンドポイントが表示されません。私が間違っていることは何ですか?

<system.serviceModel>
<services>
  <service name="MyService">
    <endpoint address =""
              binding="basicHttpBinding"
              name="EndpointBasic"
              contract="IMyService"/>

    <endpoint address ="PostMethod"
              binding="webHttpBinding"
              name="EndpointJson"
              contract="IMyService"/>
    <host>
      <baseAddresses>
        <add baseAddress ="http://localhost/WebsiteName/MyService.svc"/>
      </baseAddresses>
    </host>
  </service>
</services>
<bindings>
  <basicHttpBinding>
    <binding name="basicBinding" />
  </basicHttpBinding>
  <webHttpBinding>
    <binding name="Postbinding"
             maxBufferSize="65536"
             maxReceivedMessageSize="2000000000"
             transferMode="Streamed">
    </binding>
  </webHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="JsonBehavior">
      <webHttp defaultOutgoingResponseFormat="Json" />
    </behavior>
  </endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

ありがとう!

4

1 に答える 1

1

SOAP と REST の両方で機能する次のサービス要素エントリがあります。

<service name="XMLService.RestAndSoapService" behaviorConfiguration="default">
        <endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" bindingConfiguration="RestBinding" name="SampleService" contract="XMLService.IRestAndSoapService" />
        <endpoint address="soap" binding="basicHttpBinding" bindingConfiguration="noSecurity" contract="XMLService.IRestAndSoapService" />
      </service>

設定で注意すべき点:

  1. サービス要素で、コントラクトとサービス名が完全修飾されていません。それらが完全に修飾されていることを確認してください。インターフェイスとともに名前空間が含まれます。

  2. bindingConfiguration を webHttpEndpoint の「Postbinding」および basicHttpBinding エンドポイントの「basicBinding」として指定していません

したがって、上記の変更により、構成は次のようになります。

<service name="namespace.MyService">
        <endpoint address =""
                  bindingConfiguration="basicBinding"
                  binding="basicHttpBinding"
                  name="EndpointBasic"
                  contract="namespace.IMyService"/>

        <endpoint address ="PostMethod"
                  bindingConfiguration="Postbinding"
                  binding="webHttpBinding"
                  name="EndpointJson"
                  contract="namespace.IMyService"/>
        <host>
          <baseAddresses>
            <add baseAddress ="http://localhost/WebsiteName/MyService.svc"/>
          </baseAddresses>
        </host>
      </service>
于 2012-03-15T15:36:02.427 に答える