Jesper Lund Stocholm
Jesper Lund Stocholm

Reputation: 2013

WCF Contract first: No methods are exposed

I have received a WSDL with a bunch of XSD's and I am using these to create a WCF-service. I am using svcutil.exe to generate the service class and everything basically works fine - except that the services does not expose any methods.

The .cs-file generated from svcutil contains the following interface:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://serviceplatformen.dk/xml/wsdl/soap11/DistributionService/1/port", ConfigurationName="DistributionReceiverWebServicePort")]
public interface DistributionReceiverWebServicePort
{

    [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")]
    [System.ServiceModel.FaultContractAttribute(typeof(serviceplatformen.dk.xml.wsdl.soap11.DistributionService._1.types.TransportkvitteringType), Action="", Name="TransportKvittering", Namespace="http://serviceplatformen.dk/xml/wsdl/soap11/DistributionService/1/types")]
    [System.ServiceModel.XmlSerializerFormatAttribute()]
    FordelingsobjektModtagResponse FordelingsobjektModtag(FordelingsobjektModtagRequest request);
}

And the types in question look like this:

[System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "4.0.30319.33440")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://serviceplatformen.dk/xml/wsdl/soap11/DistributionService/1/types")]
public partial class ForretningskvitteringType
{

    private ForretningsValideringsKodeType forretningsValideringsKodeField;

    private string begrundelseField;

    private FejlType[] fejlListeField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Order=1)]
    public string Begrundelse
    {
        get
        {
            return this.begrundelseField;
        }
        set
        {
            this.begrundelseField = value;
        }
    }

    ...
}

I have noticed that none of the types are decorated with the DataContract/DataMember attribute. Is that required, or are they covered by the other attributes on the types?

The WSDL exposed by my service (without any operations) is this:

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions name="FKService" targetNamespace="http://serviceplatformen.dk/xml/wsdl/soap11/DistributionService/1/port" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://serviceplatformen.dk/xml/wsdl/soap11/DistributionService/1/port" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
  <wsp:Policy wsu:Id="MetadataExchangeHttpBinding_DistributionReceiverWebServicePort_policy">
    <wsp:ExactlyOne>
      <wsp:All>
        <wsaw:UsingAddressing/>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsdl:types/>
  <wsdl:portType name="DistributionReceiverWebServicePort"/>
  <wsdl:binding name="BasicHttpBinding_DistributionReceiverWebServicePort" type="tns:DistributionReceiverWebServicePort">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
  </wsdl:binding>
  <wsdl:binding name="MetadataExchangeHttpBinding_DistributionReceiverWebServicePort" type="tns:DistributionReceiverWebServicePort">
    <wsp:PolicyReference URI="#MetadataExchangeHttpBinding_DistributionReceiverWebServicePort_policy"/>
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
  </wsdl:binding>
  <wsdl:service name="FKService">
    <wsdl:port name="BasicHttpBinding_DistributionReceiverWebServicePort" binding="tns:BasicHttpBinding_DistributionReceiverWebServicePort">
      <soap:address location="http://localhost:8082/FKService/"/>
    </wsdl:port>
    <wsdl:port name="MetadataExchangeHttpBinding_DistributionReceiverWebServicePort" binding="tns:MetadataExchangeHttpBinding_DistributionReceiverWebServicePort">
      <soap12:address location="http://localhost:8082/FKService/mex"/>
      <wsa10:EndpointReference>
        <wsa10:Address>http://localhost:8082/FKService/mex</wsa10:Address>
      </wsa10:EndpointReference>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

I think I am missing something very obvious, but what?

Upvotes: 4

Views: 1320

Answers (1)

Jesper Lund Stocholm
Jesper Lund Stocholm

Reputation: 2013

Apparently svcutil adds ReplyAction="*" to the operation contract, and that causes the weird behaviour.

After removing this specification of the OperationContractAttribute, the problem went away.

[System.ServiceModel.ServiceContractAttribute(Namespace="http://tempuri.org/xml/wsdl/soap11/DistributionService/1/port", ConfigurationName="DistributionReceiverWebServicePort")]
public interface DistributionReceiverWebServicePort
{
    [System.ServiceModel.OperationContractAttribute(Action="")]
    [System.ServiceModel.FaultContractAttribute(typeof(TransportkvitteringType), Action="", Name="TransportKvittering", Namespace="http://tempuri.org/xml/wsdl/soap11/DistributionService/1/types")]
    [System.ServiceModel.XmlSerializerFormatAttribute()]
    FordelingsobjektModtagResponse FordelingsobjektModtag(FordelingsobjektModtagRequest request);
}

See also

https://shishkin.wordpress.com/2007/03/21/wcf-actions-asterisk-and-metadata/

and

https://social.msdn.microsoft.com/Forums/vstudio/en-US/41f5fe72-3ab3-4741-867e-a93119fe62aa/svcutil-generates-replyaction

Upvotes: 3

Related Questions