0

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?

seanicus
  • 1,141
  • 4
  • 19
  • 40
  • you need to remove the base address in the config for a start - for IIS hosting the base address is the .svc file – Richard Blewett Jun 27 '11 at 17:19
  • I just followed your suggestion. after removing the base address, I couldn't access the service from http://caaditl20bz3.national.edu/EnterpriseReportingWS.ERPService.svc/soap12 or http://caaditl20bz3.national.edu/EnterpriseReportingWS.ERPService.svc – seanicus Jun 27 '11 at 17:27
  • or am I misunderstanding your suggestion? – seanicus Jun 27 '11 at 17:27
  • 1
    Side-note; Very similar to this question: http://stackoverflow.com/questions/1182725/multiple-endpoints-under-iis although that one is also unanswered. If someone finds an answer, they may want to apply it to both questions. – CodingWithSpike Jun 27 '11 at 18:54
  • Are you hosting in IIS? What is the machine name and virtual directory name? – Richard Blewett Jun 28 '11 at 06:21

1 Answers1

0

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" />
Jakob Christensen
  • 14,826
  • 2
  • 51
  • 81