Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WCF 4和多端点绑定_Wcf_Wcf Binding_Wcf 4 - Fatal编程技术网

WCF 4和多端点绑定

WCF 4和多端点绑定,wcf,wcf-binding,wcf-4,Wcf,Wcf Binding,Wcf 4,我希望能够公开与basicHttpBinding和webHttpBinding相同的合同和服务,以便能够进行POST调用。不知何故,当我查看wsdl时,它从未看到webHttpBinding的端点。我做错了什么 <system.serviceModel> <services> <service name="MyService"> <endpoint address ="" binding="basicHttpBin

我希望能够公开与basicHttpBinding和webHttpBinding相同的合同和服务,以便能够进行POST调用。不知何故,当我查看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" />


谢谢

我有以下服务元素条目,可用于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>

在配置中需要注意的要点:

  • 在服务元素中,您的合同和服务名称不是完全限定的。确保它们是完全限定的,即包括名称空间和接口

  • 您尚未将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>
    
    
    
    我还想提一下,我想从一个html页面为这个webhttpbinding调用一篇帖子。。。另外,如果您希望应用“JsonBehavior”,请将
    behaviorConfiguration=“JsonBehavior”
    属性添加到“PostMethod”端点元素中。好的,这似乎起到了作用。。。然而,当我转到我得到一个页面,说端点未找到。nm。。。我想我忘了PostMethod是地址。。除此之外,我还需要添加操作。嗯