2015-01-15 5 views
0

WSE3 웹 서비스 클라이언트 코드를 WCF로 변환WSE3 웹 서비스 클라이언트 코드를 WCF로 변환

안녕하세요. 전문가가 다음 WSE3 웹 서비스 클라이언트 코드를 가능한 (가능한 한 많이) WCF 코드 (가능한 코드와 전체 코드의 구성이 바람직 함)로 변환 할 수 있다면 많은 도움이 될 것입니다. ChannelFactory 클래스를 사용하는 몇 가지 예제를 보았지만 클리너/더 짧은 방법이있을 수 있습니다.

호출되는 타사 웹 서비스는 다음과 같습니다. HTTPS, EndPoint는 ASMX 파일, SOAP 1.1 및 ws-security를 ​​사용합니다. 작업 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) 

예 비누 요청은 다음과 같습니다

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

은 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> 
+1

'<' and '>'을 올바르게 사용하도록 XML을 수정하십시오. –

+0

안녕하세요. 나는 당신을 위해 xml을 고쳤다. –

+0

내 눈은 당신에게 감사합니다. –

답변

0

프록시 클래스를 생성 wsdl.exe를 사용하거나 또는 Visual Studio에서 서비스 참조를 추가하여 그러면 필요한 프록시가 만들어집니다. 프록시에는 원하는 메서드가 있습니다. 필요한 매개 변수를 전달하면 좋을 것입니다.