为WF4工作流服务添加服务引用不会创建客户端(ClientBase)

时间:2013-07-11 15:01:44

标签: visual-studio-2012 workflow-foundation-4

我创建了一个非常简单的WF4服务,它只包含接收/发送序列。我已经部署到AppFabric,它通过浏览器查看时按预期响应(即“你已经创建了一个服务”...... wsdl links ..等等)

我在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();

为什么不通过服务参考流程生成Client类?以下是完整的wsdl。

我遇到了一个类似的帖子(ClientBase classes are not available in Reference.cs file),但我看不出与我的问题有直接关系。我的名称空间不受默认值的限制。

感谢阅读!

<?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>

1 个答案:

答案 0 :(得分:0)

对于任何陷入此问题的人来说,这就是问题所在。我已经为控制台服务应用程序生成了Web引用。默认情况下,这些实现为工作流活动,而不是客户端包装器的一部分。一旦我意识到我的误解,实例化很简单。