0

Unlike ASMX Web services, WCF Web services seem to break the WSDL up into a number of files.

My problem is that when I try to generate a proxy from a server that isn't the server, it'll get to the WSDL but then inside the WSDL's it'll have a number of imports, that it cannot access from the outside the server.

eg. this is one of the imports in my WSDL

http://alumninetworkservice.hha.test.idc:1315 is an internal address - I cannot access it from outside the server. Is there a way I can set up my service so that these WSDL references will be pointing to their internet URL?

Thanks

EDIT : I have pasted the configuration settings below.

This is on the server side.

  <system.serviceModel>
    <services>
      <service name="Alumni.WebService.IAlumniWebService">
        <endpoint binding="wsHttpBinding"
                  contract="Alumni.WebService.IAlumniWebService">
        </endpoint>
      </service>
    </services>
    <bindings>
      <wsHttpBinding>
        <binding maxReceivedMessageSize="2000000" >
          <readerQuotas  maxStringContentLength="2147483647"   />
          <security mode="Transport">
            <!--<transport clientCredentialType="None" proxyCredentialType="None"
                  realm="" />
            <message clientCredentialType="None" algorithmSuite="Default" />-->
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"  />
          <serviceDebug includeExceptionDetailInFaults="false"/>
          <useRequestHeadersForMetadataAddress />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
Diskdrive
  • 18,107
  • 27
  • 101
  • 167
  • An alternative is to implement a shared contract-only DLL, and avoid using service references altogether. – Merlyn Morgan-Graham Jun 06 '11 at 06:41
  • Possible duplicate of: http://stackoverflow.com/questions/1073446/how-to-retrieve-a-single-file-wsdl-for-a-wcf-service-flat-wsdl – Johann Blais Jun 06 '11 at 06:55
  • @Johann : so the solution is to flatten the WSDL structure? Is there no way to get WCF to just reference the internet URL instead of the internal URL? – Diskdrive Jun 06 '11 at 07:01
  • @stickman: That is a possible solution. What URL are you using to access your WSDL? – Johann Blais Jun 06 '11 at 07:09
  • @Johann : This is the URL of the WSDL. http://alumninetworkservice.dev.idc.hosts.network/AlumniWebService.svc?wsdl which works, but the references inside it is pointing to internal URLs – Diskdrive Jun 06 '11 at 07:31
  • @stickman: is it the address configured in the service configuration? Or is the service configured with a internal address that is translated to a public address by a network equipment? – Johann Blais Jun 06 '11 at 08:28
  • @johann : that's interesting. I have to ask the infrastructure people how http://alumninetworkservice.dev.idc.hosts.network/AlumniWebService.svc is created. It would actually matter wouldn't it? I would need the web service to understand the same rules... – Diskdrive Jun 06 '11 at 23:18

1 Answers1

2

Use useRequestHeadersForMetadataAddress behavior in the configuration of your service to overcome the problem. By default WCF always uses local address / dns name defined for the endpoint in WSDL. The behavior should enforce using the name from incoming host header (public address).

<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true" />
      <useRequestHeadersForMetadataAddress />
    </behavior>
  </serviceBehaviors>
</behaviors>
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • this doesn't seem to have worked for me. Is there any other suggestion you can think of? Johann Blais (up above) has alerted me to the fact that the "public address" is a subdomain that is probably produced by some IIS configuration on the server. – Diskdrive Jun 06 '11 at 23:22
  • @stickman strange because it seems to work for this guy on another question: http://stackoverflow.com/questions/6202745/confused-by-use-of-host-name-in-wsdl-file-in-c-web-service – Johann Blais Jun 07 '11 at 05:09
  • @Johann : Yeah it's strange - looking around at other threads, it seems to work for everybody else but me. It turns out that we'll probably just not expose the WSDL as there are relatively few clients who will need it, we'll just give them the proxy DLL via email. However, thanks both for your help - I've pasted the code up in the original question so if it's glaringly obvious that I've missed the point (I'm far from an expert in WCF), please let me know. – Diskdrive Jun 07 '11 at 05:43
  • @Johann: AFAIK useRequestHeadersForMetadataAddress is supported on [Framework 4](http://msdn.microsoft.com/en-us/library/ee816894.aspx) and higher, perhaps that's your case? – grudolf Oct 12 '11 at 10:31