views:

637

answers:

2

Hello everyone,

I am referring from VSTS2008 (C# console application, using .Net 3.5) by using Add Service Reference function to add reference to a WCF service hosted in IIS 7.0 in another machine in the same LAN. I find the client side app.config generated automatically is very strange. Here is the content,

My confusion is the end point address is "http://labtest1/WcfDemo/service.svc/10.10.200.10/wcfDemo", but actually it should be "http://labtest1/WcfDemo/service.svc" (I can use http://labtest1/WcfDemo/service.svc in IE to get the WSDL from WCF hosting machine labtest1). But I cannot get WSDL from IE by using address "http://labtest1/WcfDemo/service.svc/10.10.200.10/wcfDemo". The machine labtest1 has an internal IP address 10.10.200.10. Any ideas what is wrong?

BTW: but the client functions works, i.e. the call to WCF endpoint methods could return expected results. How can a "wrong" endpoint address return a correct results?

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IOrderManagement" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://labtest1/WcfDemo/service.svc/10.10.200.10/wcfDemo"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IOrderManagement"
                contract="ServiceReference1.IOrderManagement" name="BasicHttpBinding_IOrderManagement" />
        </client>
    </system.serviceModel>
</configuration>

EDIT 1:

This is the configuration file (web.config) I am using at IIS 7.0 side. I put service.svc under WcfDemo sub-directory of machine labtest1's default web site (port 80). I think the correct endpoint address should be "http://labtest1/WcfDemo/service.svc" other than "http://labtest1/WcfDemo/service.svc/10.10.200.10/wcfDemo"?

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="Foo.ServiceBehavior"
        name="Foo.OrderManagement">
        <endpoint address="" binding="basicHttpBinding" contract="Foo.IOrderManagement" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Foo.ServiceBehavior">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>
+1  A: 
marc_s
Marc, actually my confusion is from anthoer computer, when I add service reference, it is http://labtest1/WcfDemo/service.svc. From IE http://labtest1/WcfDemo/service.svc works, but http://labtest1/WcfDemo/service.svc/10.10.200.10/wcfDemo not works from IE, and works in my client application to call WCF service. I have tested using WCFTestClient.exe, the content of Config file from WCFTestClient UI contains address "http://labtest1/WcfDemo/service.svc", any ideas what is wrong?
George2
I have also tried to add a new empty console application project into the same VSTS 2008 solution, and add service reference, the result is labtest1/WcfDemo/service.svc, not the strange long address.
George2
George2: IE is only able to "see" and display the service page - which is at the address where the metadata (WSDL) is available.IE is **NOT** able to actually call the service at its real service address - your call expects a SOAP message and IE CANNOT send that SOAP message - it's not built for that. Use the WcfTestClient for that.
marc_s
1. "Use the WcfTestClient for that" -- you mean I should use the same configuration file generated by WCFTestClient? 2. I host the service.svc into WcfDemo sub-directory of IIS, I think it should be http://labtest1/WcfDemo/service.svc, other than http://labtest1/WcfDemo/service.svc/10.10.200.10/wcfDemo, because there are no two additional sub-directories. Any comments?
George2
The WcfTestClient doesn't use any of your configuration files - it will just try to establish a connection to the URL you give it, and try to download the service information from there. That should give you an idea of what service address the service is advertising itself on. WcfTEstClient also allows you to then call that service at that endpoint and see how it reacts (if it works)
marc_s
Thansk Marc, I have posted my server side configuration details, from the configuration file and also I put service.svc under WcfDemo sub-directory of machine labtest1's default web site (port 80). I think the correct endpoint address should be "http://labtest1/WcfDemo/service.svc" other than "http://labtest1/WcfDemo/service.svc/10.10.200.10/wcfDemo"? I do not know why VSTS 2008 generates such strange endpoint address and it actually works...
George2
Thanks Marc, do you know whether my issue is a known issue in VSTS2008? I did some search but not found too much information.
George2
George2: I'm not using Team System, so I couldn't say, sorry.
marc_s
Thanks Marc, have you met with such similar issues before? My confusion is endpoint address is predicable, should not be such strange. :-)
George2
Marc, I have tried to delete all service reference frmo both VSTS IDE and also the Service References sub-folder in the same solution, then add reference again using add service reference, the generated cient side app.config looks fine. Any ideas? I am very very confused.
George2
No, sorry - I've never seen anything like this, and I can't make sense of it. Maybe just a temporary fluke?
marc_s
+1  A: 

I have seen this happen when the WCF service is hosted on a server inside the domain. The utility seems to make an intranet URL in stead of an internet one.

Dabblernl
"a server inside the domain" -- what means inside the domain? On the same Windows Active Directory domain or on the same LAN? Could you provide more information please?
George2
I have tried to delete all service reference frmo both VSTS IDE and also the Service References sub-folder in the same solution, then add reference again using add service reference, the generated cient side app.config looks fine. Any ideas? I am very very confused.
George2
With "a server inside the domain" I mean indeed a windows active directory domain. I cannot help you further. I simply abandoned the utility created config file and wrote my own (for a not very demanding application)
Dabblernl
Yes, the client and server machines are both in a Windows Active Domain, but this issue happens only once, do you mean each time when you use add service reference function from VSTS inside a Widnows domain, you met with this issue? Or just met with very rare?
George2
I do think that the add service reference wizard will create an intranet endpoint when the service is hosted within the domain every time. I tried using svcutil from the command prompt, but that has the same flaw. As I said I abandoned svcutil generated code for now as my application works fine with minimal hand coded configuration settings.
Dabblernl
1. "I tried using svcutil from the command prompt, but that has the same flaw" -- you mean each time you use svcutil there is such strange endpoint issue? 2. do you know whether it is a known issue of VSTS?
George2
1. yes ;-) But I did not extensively test it. I simply abandoned it and have not needed it since.2. no ;-)
Dabblernl
It is really strange. Thanks!
George2