WCF Web Service - Unable to build proxy classes

I'm trying to build a web service using WCF. Since the service will ultimately be consumed by non-.net languages, I've been attempting to test it using "Add Web Reference" or using WSDL.exe instead of the svcutil way. I've been getting the following errors though:

From WSDL.exe - Error: Unable to import binding BasicHttpBinding_IEchoService from namespace http://tempuri.org. - - Unable to import operation Echo. - - The element http://tempuri.org/:Echo is missing.

From Add Service Reference and Add Web Reference: Metadata contains a reference that cannot be resolved: link to wsdl. The WSDL document contains links that could not be resolved. There was an error downloading http://localhost:8080/EchoService.svc?xsd=xsd0 The underlying connection was closed.

This simplified example has the same issue as the primary service.

Here's the service's Web.Config:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="EchoBehaviorConfiguration">
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <services>
      <service name="EchoService">
        <endpoint address="" 
                  behaviorConfiguration="EchoBehaviorConfiguration" 
                  binding="basicHttpBinding" 
                  contract="IEchoService" />
        <endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding" />

      </service>
    </services>
    <bindings>
      <basicHttpBinding>
      </basicHttpBinding>
      <mexHttpBinding></mexHttpBinding>
    </bindings>
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

Here's the contract/interface:

[ServiceContract]
public interface IEchoService
{
    [OperationContract]
    string Echo(string message);
}

And here's the WSDL that is generated:

<wsdl:definitions name="EchoService" targetNamespace="http://tempuri.org/">
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://localhost:8080/EchoService.svc?xsd=xsd0" namespace="http://tempuri.org/"/>
<xsd:import schemaLocation="http://localhost:8080/EchoService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="IEchoService_Echo_InputMessage">
<wsdl:part name="parameters" element="tns:Echo"/>
</wsdl:message>
<wsdl:message name="IEchoService_Echo_OutputMessage">
<wsdl:part name="parameters" element="tns:EchoResponse"/>
</wsdl:message>
<wsdl:portType name="IEchoService">
<wsdl:operation name="Echo">
<wsdl:input wsaw:Action="http://tempuri.org/IEchoService/Echo" message="tns:IEchoService_Echo_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/IEchoService/EchoResponse" message="tns:IEchoService_Echo_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BasicHttpBinding_IEchoService" type="tns:IEchoService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="Echo">
<soap:operation soapAction="http://tempuri.org/IEchoService/Echo" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="EchoService">
<wsdl:port name="BasicHttpBinding_IEchoService" binding="tns:BasicHttpBinding_IEchoService">
<soap:address location="http://localhost:8080/EchoService.svc"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

The service is currently hosted locally via IIS7. I have attempted both HTTP and HTTPS and have the same issue. If I try to chang the binding from basicHttpBinding to webHttpBinding, nothing changes in the WSDL.

Any ideas on where I'm going wrong?

UPDATE: I have the configuration now setup that if the service is running under Cassini instead of IIS, I can add service or web references to my test project. I cannot save the wsdl and use WSDL.exe to generate the proxy classes though.

So now I have 3 issues:

  1. Other than doing an aspnet_regiis to install and register WCF 4 with IIS, is there anything else I may have to do?

  2. Any idea what I need to do in order to get it working with WSDL.exe?

  3. After doing an ASMX service and comparing the WSDLs generated, they are dramatically different which makes me question how compatible WCF is at this point with non-.net languages.

Answers


I'm having the same issue due the ?xsd=xsd0 used in the WSDL. I found this link which gives this solution:

  • When you unleash your weapon (Process Monitor) on the csc.exe process (this is the compiler generating the xsd) you'll realise that the IIS identity IIS_WPG does not have access to the Windows\Temp folder. Give enough rights to the folder and viola problemo solved.

http://merill.net/2008/04/wcf-add-service-reference-gotcha-with-windows-server/


Looks like you have not specified the behavior name in the correct place

http://msdn.microsoft.com/en-us/library/system.servicemodel.servicebehaviorattribute.aspx

The result being that httpGet is not enabled for metadata.


Given your example, I think you can simplify your configuration some.

For example, if you have the .svc file, which it looks like in your wsdl's enpoint declaration, you can have:

<system.serviceModel>
  <behaviors>
    <serviceBehaviors>
      <behavior>
        <serviceMetadata httpGetEnabled="true"/>
        <serviceDebug includeExceptionDetailInFaults="false"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

then you should be able to access it via the url http://localhost:8080/EchoService.svc (assuming that it is on the local machine and listening on port 8080. Just thinking that Tomcat sometimes uses 8080 as its default port....)


Need Your Help

How can I check windows firewall status on remote server via C#

c# windows firewall

How can I check windows firewall status on remote server via C# ?

kernel density bandwidth in R

r bandwidth kernel-density

I have two vectors: 1) ~1000 sample means and 2) the corresponding ~1000 standard deviations of those means. I would like to create a kernel density plot of these data, using the sample means as the