0

我不太明白 svcutil 的输出是什么,有人可以解释一下吗?

在 vs 命令提示符中我使用了:svctil /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;
    }
}

如何/以什么方式创建 WCF 服务?我使用以下方法创建了一个服务:

在此处输入图像描述

我要实现什么?

4

2 回答 2

1

你需要区分两件事:

  • 服务(服务器端),您的 wcf 服务
  • 调用您的服务(客户端)的代理由 svcutil 创建(由 VS 使用“添加服务引用命令”)

如果您使用 svcutil 创建了代理代码,则意味着您已经知道 wsdl 合约文件的地址,这意味着服务已经存在。

您可以查看这些链接以找到一些示例:

于 2013-03-13T11:02:10.303 回答
0

您无需更改或实施任何东西,您只需使用生成的代理。

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

根据您是使用同步方法还是异步方法,您将获得适当的返回类型值或与请求相关的返回类型值;在某些情况下,只有异步方法可用(à la Silverlight)。

于 2013-03-13T11:01:03.993 回答