根据OASIS标准实施的客户消费型Web服务(印度所得税部门的电子归档安全Web服务)

时间:2019-05-22 07:39:36

标签: c# wcf soap ws-security oasis

我需要在C#.net中创建一个Web服务客户端,以使用印度政府所得税部门提供的Web服务来批量提交ITR。他们提供了一个Web服务用户手册,说的是

  

Web服务是基于OASIS标准实现的。这些Web服务堆栈支持WS-Security和WS-SecurityPolicy来配置安全性处理。

对此我是陌生的,发现一些博客说我可以使用WCF客户端或WSE 2.0 / 3.0来使用基于ws-security的Web服务,

任何人都可以提供关于我应该使用哪些服务(WCF客户端或WSE 2.0 / 3.0)的想法,以及一些逐步开发指南以实现该目标吗?

e-Filing Secure Web Service User Manual

以下是发送请求的要求。

  1. SOAP请求的标头应包含用户必须发送的用户名令牌和时间戳。用户名令牌提供了一种使用WS-Security表示用户名(在电子归档中注册的用户ID)和密码对的标准方法。该凭据用于授权请求者(即用户和请求)。

  2. 对于每个请求,SOAP请求中的UniqueRequestID应该是唯一的。

  3. 该请求必须使用用户的私钥进行数字签名。签名包括密钥信息元素,其中包含X.509证书详细信息。电子归档服务器需要使用它来验证签名者。

    必须对SOAP请求中的以下元素进行签名

    • 时间戳
    • UsernameToken
    • 身体
  4. 签名后,必须使用电子归档的公钥对请求进行加密。使用URI

    以下内容是使用电子归档的公钥加密的

    • UsernameToken
    • 身体

以下是Web服务的定义

  <?xml version="1.0" encoding="UTF-8" ?> 
- <wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://incometaxindiaefiling.gov.in/ditsecws" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="BulkItrService" targetNamespace="http://incometaxindiaefiling.gov.in/ditsecws">
  <wsdl:import location="https://services.incometaxindiaefiling.gov.in/e-FilingSecWS/ditsecws/BulkItrService?wsdl=EfilingWsSecPolicy.wsdl" namespace="http://incometaxindiaefiling.gov.in/ditsecws" /> 
- <wsdl:types>
- <xs:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://incometaxindiaefiling.gov.in/ditsecws/response" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" elementFormDefault="qualified" targetNamespace="http://incometaxindiaefiling.gov.in/ditsecws/response" version="1.0">
  <xs:element name="BulkItrResponse" type="tns:BulkItrResponse" /> 
  <xs:element name="DitResponse" type="tns:DitResponse" /> 
- <xs:complexType name="BulkItrResponse">
- <xs:complexContent>
- <xs:extension base="tns:DitResponse">
- <xs:sequence>
  <xs:element minOccurs="0" name="tokenNumber" type="xs:string" /> 
  </xs:sequence>
  </xs:extension>
  </xs:complexContent>
  </xs:complexType>
- <xs:complexType name="DitResponse">
- <xs:sequence>
  <xs:element minOccurs="0" name="ErrorCode" type="xs:string" /> 
  <xs:element minOccurs="0" name="ErrorDesc" type="xs:string" /> 
  </xs:sequence>
  <xs:attribute name="uniqueRequestId" type="xs:string" use="required" /> 
  </xs:complexType>
  </xs:schema>
- <xs:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://incometaxindiaefiling.gov.in/ditsecws/request" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" elementFormDefault="qualified" targetNamespace="http://incometaxindiaefiling.gov.in/ditsecws/request" version="1.0">
  <xs:import namespace="http://www.w3.org/2005/05/xmlmime" /> 
  <xs:element name="BulkItrRequest" type="tns:BulkItrRequest" /> 
- <xs:complexType name="BulkItrRequest">
- <xsd:sequence>
  <xsd:element minOccurs="1" name="dataHandler" type="xs:base64Binary" xmime:expectedContentTypes="application/octet-stream" /> 
  </xsd:sequence>
- <xs:attribute name="uniqueRequestId" use="required">
- <xsd:simpleType>
- <xsd:restriction base="xs:string">
  <xsd:pattern value="[A-Za-z0-9]{10}[/-][A-Za-z0-9]{4,29}" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xs:attribute>
  </xs:complexType>
  </xs:schema>
- <xs:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://incometaxindiaefiling.gov.in/ditsecws" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns2="http://incometaxindiaefiling.gov.in/ditsecws/response" xmlns:ns1="http://incometaxindiaefiling.gov.in/ditsecws/request" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://incometaxindiaefiling.gov.in/ditsecws">
  <xs:import namespace="http://incometaxindiaefiling.gov.in/ditsecws/request" /> 
  <xs:import namespace="http://incometaxindiaefiling.gov.in/ditsecws/response" /> 
  <xs:element name="uploadBulkItr" type="tns:uploadBulkItr" /> 
  <xs:element name="uploadBulkItrResponse" type="tns:uploadBulkItrResponse" /> 
- <xs:complexType name="uploadBulkItr">
- <xs:sequence>
  <xs:element minOccurs="1" name="DitRequest" type="ns1:BulkItrRequest" /> 
  </xs:sequence>
  </xs:complexType>
- <xs:complexType name="uploadBulkItrResponse">
- <xs:sequence>
  <xs:element minOccurs="0" name="result" type="ns2:BulkItrResponse" /> 
  </xs:sequence>
  </xs:complexType>
  </xs:schema>
  </wsdl:types>
- <wsdl:message name="uploadBulkItrResponse">
  <wsdl:part element="tns:uploadBulkItrResponse" name="parameters" /> 
  </wsdl:message>
- <wsdl:message name="uploadBulkItr">
  <wsdl:part element="tns:uploadBulkItr" name="parameters" /> 
  </wsdl:message>
- <wsdl:portType name="BulkItrService">
- <wsdl:operation name="uploadBulkItr">
  <wsdl:input message="tns:uploadBulkItr" name="uploadBulkItr" /> 
  <wsdl:output message="tns:uploadBulkItrResponse" name="uploadBulkItrResponse" /> 
  </wsdl:operation>
  </wsdl:portType>
- <wsdl:binding name="BulkItrServiceSoapBinding" type="tns:BulkItrService">
  <wsp:PolicyReference xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" URI="#EfilingWsSecPolicy" /> 
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> 
- <wsdl:operation name="uploadBulkItr">
  <soap:operation soapAction="" style="document" /> 
- <wsdl:input name="uploadBulkItr">
  <soap:body use="literal" /> 
  <wsp:PolicyReference xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" URI="#EfilingPartsPolicy" /> 
  </wsdl:input>
- <wsdl:output name="uploadBulkItrResponse">
  <soap:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:service name="BulkItrService">
- <wsdl:port binding="tns:BulkItrServiceSoapBinding" name="BulkItrServicePort">
  <soap:address location="https://services.incometaxindiaefiling.gov.in/e-FilingSecWS/ditsecws/BulkItrService" /> 
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>

以下是需要使用的WS安全策略(wsdl)

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://incometaxindiaefiling.gov.in/ditsecws" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="EfilingWsSecPolicy" targetNamespace="http://incometaxindiaefiling.gov.in/ditsecws">
    <wsp:Policy xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" wsu:Id="EfilingWsSecPolicy">
        <wsp:ExactlyOne>
            <wsp:All>
                <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
                    <wsp:Policy>
                        <sp:InitiatorToken>
                            <wsp:Policy>
                                <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
                                    <wsp:Policy>
                                        <sp:WssX509V3Token10/>
                                    </wsp:Policy>
                                </sp:X509Token>
                            </wsp:Policy>
                        </sp:InitiatorToken>
                        <sp:RecipientToken>
                            <wsp:Policy>
                                <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
                                    <wsp:Policy>
                                        <sp:WssX509V3Token10/>
                                    </wsp:Policy>
                                </sp:X509Token>
                            </wsp:Policy>
                        </sp:RecipientToken>
                        <sp:AlgorithmSuite>
                            <wsp:Policy>
                                <sp:Basic128/>
                            </wsp:Policy>
                        </sp:AlgorithmSuite>
                        <sp:Layout>
                            <wsp:Policy>
                                <sp:Lax/>
                            </wsp:Policy>
                        </sp:Layout>
                        <sp:IncludeTimestamp/>
                        <sp:OnlySignEntireHeadersAndBody/>
                    </wsp:Policy>
                </sp:AsymmetricBinding>

                <sp:SignedEncryptedSupportingTokens xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
                    <wsp:Policy>
                        <sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient">
                            <wsp:Policy>
                                <sp:WssUsernameToken10/>
                            </wsp:Policy>
                        </sp:UsernameToken>
                    </wsp:Policy>
                </sp:SignedEncryptedSupportingTokens>
            </wsp:All>
        </wsp:ExactlyOne>
    </wsp:Policy>
    <wsp:Policy xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" wsu:Id="EfilingPartsPolicy">
        <wsp:ExactlyOne>
            <wsp:All>
                <sp:SignedParts xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
                    <sp:Body/>
                </sp:SignedParts>
                <sp:EncryptedParts xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
                    <sp:Body/>
                </sp:EncryptedParts>
            </wsp:All>
        </wsp:ExactlyOne>
    </wsp:Policy>
</wsdl:definitions>

预先感谢

0 个答案:

没有答案