Haroon
Haroon

Reputation: 3472

creating a service using code from svcutil

I do not really understand what has been output from svcutil, can someone explain?

in vs command prompt i used: svcitil /mc *.wsdl *.xsd /language:c#

    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="GenericInboundBrokerSoap")]
public interface GenericInboundBrokerSoap
{

    // CODEGEN: Generating message contract since element name SourceID from namespace http://tempuri.org/ is not marked nillable
    [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/BrokerInboundRequest", ReplyAction="*")]
    BrokerInboundRequestResponse BrokerInboundRequest(BrokerInboundRequestRequest request);
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
public partial class BrokerInboundRequestRequest
{

    [System.ServiceModel.MessageBodyMemberAttribute(Name="BrokerInboundRequest", Namespace="http://tempuri.org/", Order=0)]
    public BrokerInboundRequestRequestBody Body;

    public BrokerInboundRequestRequest()
    {
    }

    public BrokerInboundRequestRequest(BrokerInboundRequestRequestBody Body)
    {
        this.Body = Body;
    }
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Namespace="http://tempuri.org/")]
public partial class BrokerInboundRequestRequestBody
{

    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=0)]
    public string SourceID;

    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=1)]
    public string TokenID;

    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=2)]
    public string xml;

    public BrokerInboundRequestRequestBody()
    {
    }

    public BrokerInboundRequestRequestBody(string SourceID, string TokenID, string xml)
    {
        this.SourceID = SourceID;
        this.TokenID = TokenID;
        this.xml = xml;
    }
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
public partial class BrokerInboundRequestResponse
{

    [System.ServiceModel.MessageBodyMemberAttribute(Name="BrokerInboundRequestResponse", Namespace="http://tempuri.org/", Order=0)]
    public BrokerInboundRequestResponseBody Body;

    public BrokerInboundRequestResponse()
    {
    }

    public BrokerInboundRequestResponse(BrokerInboundRequestResponseBody Body)
    {
        this.Body = Body;
    }
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Namespace="http://tempuri.org/")]
public partial class BrokerInboundRequestResponseBody
{

    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=0)]
    public string BrokerInboundRequestResult;

    public BrokerInboundRequestResponseBody()
    {
    }

    public BrokerInboundRequestResponseBody(string BrokerInboundRequestResult)
    {
        this.BrokerInboundRequestResult = BrokerInboundRequestResult;
    }
}

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
public interface GenericInboundBrokerSoapChannel : GenericInboundBrokerSoap, System.ServiceModel.IClientChannel
{
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
public partial class GenericInboundBrokerSoapClient : System.ServiceModel.ClientBase<GenericInboundBrokerSoap>, GenericInboundBrokerSoap
{

    public GenericInboundBrokerSoapClient()
    {
    }

    public GenericInboundBrokerSoapClient(string endpointConfigurationName) : 
            base(endpointConfigurationName)
    {
    }

    public GenericInboundBrokerSoapClient(string endpointConfigurationName, string remoteAddress) : 
            base(endpointConfigurationName, remoteAddress)
    {
    }

    public GenericInboundBrokerSoapClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
            base(endpointConfigurationName, remoteAddress)
    {
    }

    public GenericInboundBrokerSoapClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
            base(binding, remoteAddress)
    {
    }

    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    BrokerInboundRequestResponse GenericInboundBrokerSoap.BrokerInboundRequest(BrokerInboundRequestRequest request)
    {
        return base.Channel.BrokerInboundRequest(request);
    }

    public string BrokerInboundRequest(string SourceID, string TokenID, string xml)
    {
        BrokerInboundRequestRequest inValue = new BrokerInboundRequestRequest();
        inValue.Body = new BrokerInboundRequestRequestBody();
        inValue.Body.SourceID = SourceID;
        inValue.Body.TokenID = TokenID;
        inValue.Body.xml = xml;

        //do the hokey pokey here?

        BrokerInboundRequestResponse retVal = ((GenericInboundBrokerSoap)(this)).BrokerInboundRequest(inValue);
        return retVal.Body.BrokerInboundRequestResult;
    }
}

How/what way can I create a WCF service? I have created a service using:

enter image description here

What do I implement?

Upvotes: 0

Views: 1400

Answers (2)

polkduran
polkduran

Reputation: 2551

You need to distinguish two things:

  • the service (server side), your wcf service
  • the proxy to call your service (client side) create by svcutil (used by VS with "Add a service reference command")

if you have created your proxy code using svcutil it means that you already know the address of a wsdl contract file, it means that a service exists already.

You can take a look at these links to find some examples:

Upvotes: 1

Grant Thomas
Grant Thomas

Reputation: 45083

You don't change or implement stuff, you just use the generated proxy.

using (var thing = new GenericInboundBrokerSoapClient()) {
  thing.CallToMethodExposedByService();
}

You will get a value of the return type proper or a request-related return type value depending on whether you use synchronous or asynchronous methods; in some cases only the asynchronous methods are available (à la Silverlight).

Upvotes: 0

Related Questions