我真的不明白svcutil的输出是什么,有人可以解释一下吗?
在vs命令提示符下我用过: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;
}
}
我如何/以何种方式创建WCF服务?我使用以下方法创建了一项服务:
我该实施什么?
答案 0 :(得分:1)
你需要区分两件事:
如果您使用svcutil创建了代理代码,则意味着您已经知道wsdl合同文件的地址,这意味着服务已经存在。
您可以查看这些链接以查找一些示例:
答案 1 :(得分:0)
您不需要更改或实现内容,只需使用生成的代理。
using (var thing = new GenericInboundBrokerSoapClient()) {
thing.CallToMethodExposedByService();
}
根据您是使用同步还是异步方法,您将获得正确的返回类型值或与请求相关的返回类型值;在某些情况下,只有异步方法可用(àla Silverlight)。