Question

I have an existing Java client that I need to build a web service for in .NET 4.0. The interface is already defined with a WSDL file so I created a class library and generated the server side stub using WSCF.blue (I also tried svcutil without success). WSCF.blue takes care of the references and adding the files (great tool :-)) so I only replaced the generated System.NotImplementedException with some code. Then I hosted the result in an ASP.NET development server.

I guess I need some additional step since I get the famous "The contract name 'WsdlWebService.IHello' could not be found in the list of contracts implemented by the service 'Hello'." when looking the service up in the browser (see WCF Contract Name 'IMyService' could not be found?). But here the is a ServiceContractAttribute of which I expect that it does the job.

I would appreciate if someone could point to what I'm missing...

This is the generated interface and implementation:



    namespace WsdlWebService
    {
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
        [System.ServiceModel.ServiceContractAttribute(Namespace="http://webservice.com", ConfigurationName="IHello")]
        public interface IHello
        {
            [System.ServiceModel.OperationContractAttribute(Action="http://webservice.com/IHello/helloName", ReplyAction="http://webservice.com/IHello/helloNameResponse")]
            [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
            [return: System.ServiceModel.MessageParameterAttribute(Name="helloNameReturn")]
            string helloName(string name);
        }

        [System.ServiceModel.ServiceBehaviorAttribute(InstanceContextMode=System.ServiceModel.InstanceContextMode.PerCall, ConcurrencyMode=System.ServiceModel.ConcurrencyMode.Single)]
        public class Hello : IHello
        {
            public virtual string helloName(string name)
            {
                return "Hello world from (via wsdl extraced server) " + name + "!";
            }
        }
    } 

This is the web.config:



    <?xml version="1.0"?>
    <configuration>
      <system.web>
        <compilation debug="false" targetFramework="4.0" />
      </system.web>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer>
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior name="MyServiceTypeBehaviors">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <services>
          <service name="WsdlWebService.Hello"
                 behaviorConfiguration="MyServiceTypeBehaviors">
            <endpoint address="" binding="basicHttpBinding"
                 contract="WsdlWebService.IHello"/>
            <endpoint contract="IMetadataExchange"
               binding="mexHttpBinding" address="mex"/>
          </service>
        </services>
      </system.serviceModel>
    </configuration>

Was it helpful?

Solution

I'm just guessing since I have not had that error, but I noticed you set the ConfigurationName = "IHello" on your service contract, but you're referring to it as "WsdlWebService.IHello" in the configuration. I would at least check if the configuration name is atomic or still only part of the namespace.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top