我创建了一个非常简单的 WF4 服务,它只包含接收/发送序列。我已部署到 AppFabric 并在通过浏览器查看时按预期响应(即,“您已创建服务”...... wsdl 链接......等)
我在VS2012中添加了一个服务引用,成功完成。但是,没有对 ClientBase 类 (ServiceClient) 的引用。
但是,如果不是添加服务引用,而是通过创建 Service2 类
svcutil.exe http://localhost/TrinityServices/Testbed/Service2.xamlx?wsdl
生成的 Service2.cs 清楚地声明了 ServiceClient,
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class ServiceClient : System.ServiceModel.ClientBase<IService>, IService
我可以声明:
var svc = new ServiceClient();
.
.
string p = svc.GetData();
为什么不是通过服务引用过程生成客户端类?以下是完整的 wsdl。
我遇到了一篇类似的帖子(ClientBase 类在 Reference.cs 文件中不可用),但我看不出与我的问题有直接关系。我的命名空间不受默认值的影响。
谢谢阅读!
<?xml version="1.0" ?>
<wsdl:definitions name="Service2" targetNamespace="http://tempuri.org/" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsp:Policy wsu:Id="NetNamedPipeBinding_IService_policy">
<wsp:ExactlyOne>
<wsp:All>
<msb:BinaryEncoding xmlns:msb="http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1"/>
<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:TransportToken>
<wsp:Policy>
<msf:WindowsTransportSecurity xmlns:msf="http://schemas.microsoft.com/ws/2006/05/framing/policy">
<msf:ProtectionLevel>
EncryptAndSign
</msf:ProtectionLevel>
</msf:WindowsTransportSecurity>
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256/>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Strict/>
</wsp:Policy>
</sp:Layout>
</wsp:Policy>
</sp:TransportBinding>
<wsaw:UsingAddressing/>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="anyType" nillable="true" type="xs:anyType"/>
<xs:element name="anyURI" nillable="true" type="xs:anyURI"/>
<xs:element name="base64Binary" nillable="true" type="xs:base64Binary"/>
<xs:element name="boolean" nillable="true" type="xs:boolean"/>
<xs:element name="byte" nillable="true" type="xs:byte"/>
<xs:element name="dateTime" nillable="true" type="xs:dateTime"/>
<xs:element name="decimal" nillable="true" type="xs:decimal"/>
<xs:element name="double" nillable="true" type="xs:double"/>
<xs:element name="float" nillable="true" type="xs:float"/>
<xs:element name="int" nillable="true" type="xs:int"/>
<xs:element name="long" nillable="true" type="xs:long"/>
<xs:element name="QName" nillable="true" type="xs:QName"/>
<xs:element name="short" nillable="true" type="xs:short"/>
<xs:element name="string" nillable="true" type="xs:string"/>
<xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte"/>
<xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt"/>
<xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong"/>
<xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort"/>
<xs:element name="char" nillable="true" type="tns:char"/>
<xs:simpleType name="char">
<xs:restriction base="xs:int"/>
</xs:simpleType>
<xs:element name="duration" nillable="true" type="tns:duration"/>
<xs:simpleType name="duration">
<xs:restriction base="xs:duration">
<xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?"/>
<xs:minInclusive value="-P10675199DT2H48M5.4775808S"/>
<xs:maxInclusive value="P10675199DT2H48M5.4775807S"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="guid" nillable="true" type="tns:guid"/>
<xs:simpleType name="guid">
<xs:restriction base="xs:string">
<xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}"/>
</xs:restriction>
</xs:simpleType>
<xs:attribute name="FactoryType" type="xs:QName"/>
<xs:attribute name="Id" type="xs:ID"/>
<xs:attribute name="Ref" type="xs:IDREF"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="IService_GetData_InputMessage">
<wsdl:part element="q1:int" name="int" xmlns:q1="http://schemas.microsoft.com/2003/10/Serialization/"/>
</wsdl:message>
<wsdl:message name="IService_GetData_OutputMessage">
<wsdl:part element="q2:string" name="string" xmlns:q2="http://schemas.microsoft.com/2003/10/Serialization/"/>
</wsdl:message>
<wsdl:portType name="IService">
<wsdl:operation name="GetData">
<wsdl:input message="tns:IService_GetData_InputMessage" wsaw:Action="http://tempuri.org/IService/GetData"/>
<wsdl:output message="tns:IService_GetData_OutputMessage" wsaw:Action="http://tempuri.org/IService/GetDataResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BasicHttpBinding_IService" type="tns:IService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetData">
<soap:operation soapAction="http://tempuri.org/IService/GetData" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="NetNamedPipeBinding_IService" type="tns:IService">
<wsp:PolicyReference URI="#NetNamedPipeBinding_IService_policy"/>
<soap12:binding transport="http://schemas.microsoft.com/soap/named-pipe"/>
<wsdl:operation name="GetData">
<soap12:operation soapAction="http://tempuri.org/IService/GetData" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Service2">
<wsdl:port binding="tns:BasicHttpBinding_IService" name="BasicHttpBinding_IService">
<soap:address location="http://localhost/TrinityServices/Testbed/Service2.xamlx"/>
</wsdl:port>
<wsdl:port binding="tns:NetNamedPipeBinding_IService" name="NetNamedPipeBinding_IService">
<soap12:address location="net.pipe://ip-0a7e0a82/TrinityServices/Testbed/Service2.xamlx"/>
<wsa10:EndpointReference>
<wsa10:Address>
net.pipe://ip-0a7e0a82/TrinityServices/Testbed/Service2.xamlx
</wsa10:Address>
<Identity xmlns="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity">
<Spn>
host/ip-0A7E0A82
</Spn>
</Identity>
</wsa10:EndpointReference>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>