简体   繁体   中英

What's wrong with my wcf endpoints?

I am trying to create a wcf service with two endpoints, one SOAP 1.1 and the other SOAP 1.2. Here is my config:

<?xml version="1.0"?>
<configuration>

<configSections>
</configSections>
<connectionStrings>
<add name="ProgramInformationWS.Properties.Settings.IMTConnectionString" connectionString="Data Source=DLADD00001;Initial Catalog=IMT;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true"/>
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's 
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
  <service name="EnterpriseReportingWS.ERPService" behaviorConfiguration="ERPService.Behavior">
      <endpoint address="soap" binding="basicHttpBinding" bindingConfiguration="" contract="EnterpriseReportingWS.IERPService">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
      <endpoint address="soap12" binding="wsHttpBinding" bindingConfiguration="" contract="EnterpriseReportingWS.IERPService">
          <identity>
              <dns value="localhost"/>
          </identity>
      </endpoint>         
    <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange"/>
    <host>
      <baseAddresses>
        <add baseAddress="http://MyServerHere/ERPService/"/>
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
<serviceBehaviors>
    <behavior name="ERPService.Behavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
</system.serviceModel>

<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>

What I am trying to configure here is that when I hit

http://caaditl20bz3.national.edu/ERPService/EnterpriseReportingWS.ERPService.svc/soap

I get SOAP 1.1 and when I hit

http://caaditl20bz3.national.edu/ERPService/EnterpriseReportingWS.ERPService.svc/soap12

I get SOAP 1.2. However, the behavior I am getting is that neither of those resolve, and the only way I can access my service is from

http://caaditl20bz3.national.edu/ERPService/EnterpriseReportingWS.ERPService.svc

What have I screwed up?

UPDATE: By removing the wshttpbinding endpoint and using the basichttpbinding endpoint only in my config, I can get get SOAP 1.1. What do I need to do to be able to make both available?

This is one way to do it:

<system.serviceModel>
  <services>
    <service behaviorConfiguration="Service1Behavior" name="WcfTest.Service1">
      <endpoint address="" contract="WcfTest.IService1" binding="wsHttpBinding" />
      <endpoint address="/basic/" binding="basicHttpBinding" contract="WcfTest.IService1" />
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="Service1Behavior">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

In the above example I put wsHttpBinding at the root address http://server/service1.svc while basicHttpBinding can be found at http://server/service1.svc/basic/ . Note that you will not be able to see http://server/service1.svc/basic/ in a browser but that does not mean that it is not there.

To add a reference to the wsHttpBinding endpoint in Visual Studio just add a service reference as you would normally do. To add a reference to the basicHttpBinding endpoint, go to the advanded settings dialog of the "Add service reference" screen and choose "Add Web Reference".

Note that to generate the client proxies for the basicHttpBinding endpoint you have to use http://server/service1.svc and not http://server/service1.svc/basic/ when adding the web reference. But if you take a closer look at the generated .config file on the client you will see that it uses the /basic/ endpoint as it should:

<endpoint address="http://server/Service1.svc/basic/"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
    contract="Service1Reference.IService1" name="BasicHttpBinding_IService1" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM