简体   繁体   English

将WSE3 Web服务客户端代码转换为WCF

[英]Convert WSE3 Web Service Client Code to WCF

Convert WSE3 Web Service Client Code to WCF 将WSE3 Web服务客户端代码转换为WCF

Hi. 你好。 It would be much appreciated if an expert could be able to convert the following WSE3 web service client code to some working(well as much as possible) WCF code(preferable with configuration in code and entire code as short as can be) please? 如果专家能够将以下WSE3 Web服务客户端代码转换为某些有效的WCF代码(最好在代码中进行配置,并尽可能缩短整个代码),将不胜感激? I've seen some examples using the ChannelFactory class but there may be a cleaner/shorter way. 我已经看到了一些使用ChannelFactory类的示例,但可能会有更简洁的方法。

The 3rd Party web service being called is: HTTPS, EndPoint is ASMX file, SOAP 1.1, and using ws-security. 被调用的第3方Web服务是:HTTPS,EndPoint是ASMX文件,SOAP 1.1,并且使用ws-security。 The working WSE3 code is: 有效的WSE3代码是:

    Dim ExpCertificate As New X509Certificate2
    ExpCertificate = New X509Certificate2("<pfx file>", "<password>")
    Dim waspservice As New TokenService
    waspservice.ClientCertificates.Add(ExpCertificate)
    waspservice.Url = "https://somesite.asmx"
    Dim res As String = waspservice.STS("<WASPAuthenticationRequest><ApplicationName>Example Client</ApplicationName><AuthenticationLevel>CertificateAuthentication</AuthenticationLevel><AuthenticationParameters/></WASPAuthenticationRequest>")
    Response.Write(res & vbCrLf & vbCrLf)

An example soap request is: 一个示例肥皂请求是:

<wsse:Security>

<wsu:Timestampwsu:Id="Timestamp-2b27a32b-ca9c-4405-b377-4444f63c8f29">

<wsu:Created>2011-02-20T16:36:54Z</wsu:Created>

<wsu:Expires>2011-02-20T16:41:54Z</wsu:Expires>

</wsu:Timestamp>

<wsse:BinarySecurityToken ValueType="CompanyWASP" EncodingType="wsse:Base64Binary" wsu:Id="SecurityToken-f64439f9-c12c-4d09-ac3d-fc478ad19775">MjAtRTctQ0YtMTUtN0EtODEtNTk.</wsse:BinarySecurityToken>

</wsse:Security>

</soap:Header>

<soap:Body>

<! -- SOAP content for the service call -- >

</soap:Body>

The WSDL is: WSDL是:

<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.uk.company.com/WASP/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetNamespace="http://www.uk.company.com/WASP/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://www.uk.company.com/WASP/">
      <s:element name="STS">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="authenticationBlock" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="STSResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="STSResult" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="string" nillable="true" type="s:string" />
    </s:schema>
  </wsdl:types>
  <wsdl:message name="STSSoapIn">
    <wsdl:part name="parameters" element="tns:STS" />
  </wsdl:message>
  <wsdl:message name="STSSoapOut">
    <wsdl:part name="parameters" element="tns:STSResponse" />
  </wsdl:message>
  <wsdl:message name="STSHttpGetIn">
    <wsdl:part name="authenticationBlock" type="s:string" />
  </wsdl:message>
  <wsdl:message name="STSHttpGetOut">
    <wsdl:part name="Body" element="tns:string" />
  </wsdl:message>
  <wsdl:message name="STSHttpPostIn">
    <wsdl:part name="authenticationBlock" type="s:string" />
  </wsdl:message>
  <wsdl:message name="STSHttpPostOut">
    <wsdl:part name="Body" element="tns:string" />
  </wsdl:message>
  <wsdl:portType name="TokenServiceSoap">
    <wsdl:operation name="STS">
      <wsdl:input message="tns:STSSoapIn" />
      <wsdl:output message="tns:STSSoapOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:portType name="TokenServiceHttpGet">
    <wsdl:operation name="STS">
      <wsdl:input message="tns:STSHttpGetIn" />
      <wsdl:output message="tns:STSHttpGetOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:portType name="TokenServiceHttpPost">
    <wsdl:operation name="STS">
      <wsdl:input message="tns:STSHttpPostIn" />
      <wsdl:output message="tns:STSHttpPostOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="TokenServiceSoap" type="tns:TokenServiceSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
    <wsdl:operation name="STS">
      <soap:operation soapAction="http://www.uk.company.com/WASP/STS" 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="TokenServiceHttpGet" type="tns:TokenServiceHttpGet">
    <http:binding verb="GET" />
    <wsdl:operation name="STS">
      <http:operation location="/STS" />
      <wsdl:input>
        <http:urlEncoded />
      </wsdl:input>
      <wsdl:output>
        <mime:mimeXml part="Body" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="TokenServiceHttpPost" type="tns:TokenServiceHttpPost">
    <http:binding verb="POST" />
    <wsdl:operation name="STS">
      <http:operation location="/STS" />
      <wsdl:input>
        <mime:content type="application/x-www-form-urlencoded" />
      </wsdl:input>
      <wsdl:output>
        <mime:mimeXml part="Body" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="TokenService">
    <documentation xmlns="http://schemas.xmlsoap.org/wsdl/">company Token Service</documentation>
    <wsdl:port name="TokenServiceSoap" binding="tns:TokenServiceSoap">
      <soap:address location="https://secure.authenticator.uat.uk.company.com/WaspAuthenticator/TokenService.asmx" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

Generate proxy class either of using wsdl.exe OR by adding service reference in visual studio. 使用wsdl.exe或通过在Visual Studio中添加服务引用来生成代理类。 That will create required proxy. 这将创建所需的代理。 Proxy will have methods which you want to call. 代理将具有您要调用的方法。 Pass in required parameters and you should be good. 传递所需的参数,您应该会很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM