使用groovy-wslite

时间:2016-05-19 14:13:16

标签: web-services soap groovy wsdl

我需要从groovy调用Soap服务。我想使用groovy-wslite库。 我对简单服务没有任何问题,但我使用WS-Security和WS-Reliable Messaging遇到了问题。我在客户端站点上有示例配置:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
  <bindings>
    <wsHttpBinding>
      <binding name="WSHttpBinding_IRestrictionImport" closeTimeout="00:01:00"
        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
        bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
        maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
        textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
          maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        <reliableSession ordered="true" inactivityTimeout="00:10:00"
          enabled="false" />
        <security mode="TransportWithMessageCredential">
          <transport clientCredentialType="None" proxyCredentialType="None"
            realm="" />
          <message clientCredentialType="UserName" negotiateServiceCredential="true"
            algorithmSuite="Default" />
        </security>
      </binding>
    </wsHttpBinding>
  </bindings>
  <client>
    <endpoint address="https://test.ceidg.gov.pl/CEIDG.Services.Import/RestrictionImport.svc"
        binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IRestrictionImport"
        contract="RestrictionImportService.IRestrictionImport" name="WSHttpBinding_IRestrictionImport" />
  </client>
</system.serviceModel>
</configuration>

WSDL:

wsdl:definitions name="RestrictionImport" targetNamespace="http://zeto.bialystok.pl"><wsp:Policy wsu:Id="WSHttpBinding_IRestrictionImport_policy">
<wsp:ExactlyOne>
    <wsp:All>
        <sp:TransportBinding>
            <wsp:Policy>
                <sp:TransportToken>
                    <wsp:Policy>
                        <sp:HttpsToken RequireClientCertificate="false"/>
                    </wsp:Policy>
                </sp:TransportToken>
                <sp:AlgorithmSuite>
                    <wsp:Policy>
                        <sp:Basic256/>
                    </wsp:Policy>
                </sp:AlgorithmSuite>
                <sp:Layout>
                    <wsp:Policy>
                        <sp:Strict/>
                    </wsp:Policy>
                </sp:Layout>
                <sp:IncludeTimestamp/>
            </wsp:Policy>
        </sp:TransportBinding>
        <sp:EndorsingSupportingTokens>
            <wsp:Policy>
                <sp:SecureConversationToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
                    <wsp:Policy>
                        <sp:BootstrapPolicy>
                            <wsp:Policy>
                                <sp:SignedParts>
                                    <sp:Body/>
                                    <sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing"/>
                                    <sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing"/>
                                    <sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing"/>
                                    <sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing"/>
                                    <sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing"/>
                                    <sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing"/>
                                    <sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing"/>
                                </sp:SignedParts>
                                <sp:EncryptedParts>
                                    <sp:Body/>
                                </sp:EncryptedParts>
                                <sp:TransportBinding>
                                    <wsp:Policy>
                                        <sp:TransportToken>
                                            <wsp:Policy>
                                                <sp:HttpsToken RequireClientCertificate="false"/>
                                            </wsp:Policy>
                                        </sp:TransportToken>
                                        <sp:AlgorithmSuite>
                                            <wsp:Policy>
                                                <sp:Basic256/>
                                            </wsp:Policy>
                                        </sp:AlgorithmSuite>
                                        <sp:Layout>
                                            <wsp:Policy>
                                                <sp:Strict/>
                                            </wsp:Policy>
                                        </sp:Layout>
                                        <sp:IncludeTimestamp/>
                                    </wsp:Policy>
                                </sp:TransportBinding>
                                <sp:SignedSupportingTokens>
                                    <wsp:Policy>
                                        <sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
                                            <wsp:Policy>
                                                <sp:WssUsernameToken10/>
                                            </wsp:Policy>
                                        </sp:UsernameToken>
                                    </wsp:Policy>
                                </sp:SignedSupportingTokens>
                                <sp:Wss11>
                                    <wsp:Policy/>
                                </sp:Wss11>
                                <sp:Trust10>
                                    <wsp:Policy>
                                        <sp:MustSupportIssuedTokens/>
                                        <sp:RequireClientEntropy/>
                                        <sp:RequireServerEntropy/>
                                    </wsp:Policy>
                                </sp:Trust10>
                            </wsp:Policy>
                        </sp:BootstrapPolicy>
                    </wsp:Policy>
                </sp:SecureConversationToken>
            </wsp:Policy>
        </sp:EndorsingSupportingTokens>
        <sp:Wss11>
            <wsp:Policy/>
        </sp:Wss11>
        <sp:Trust10>
            <wsp:Policy>
                <sp:MustSupportIssuedTokens/>
                <sp:RequireClientEntropy/>
                <sp:RequireServerEntropy/>
            </wsp:Policy>
        </sp:Trust10>
        <wsaw:UsingAddressing/>
    </wsp:All>
</wsp:ExactlyOne>

                                                                                                                                                                                                                                                                                                https://test.ceidg.gov.pl/CEIDG.Services.Import/RestrictionImport.svc              

我有用于身份验证的用户名和密码。 我试图使用这个XML调用groovy服务:

def client = new SOAPClient("https://test.ceidg.gov.pl/ceidg.public.api/APIService.svc")
response = client.send(
    """<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
        <soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
            <wsse:Security mode="TransportWithMessageCredential" soap:mustUnderstand="true" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                <wsse:UsernameToken wsu:Id="UsernameToken-C42BA6EAC6DBDE07EC14636522574269">
                    <wsse:Username>USER</wsse:Username>
                    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password>
                    <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">AceynGmXO0uy+sRgBBEj8Q==</wsse:Nonce>
                    <wsu:Created>$data</wsu:Created>
                </wsse:UsernameToken>
            </wsse:Security>
            <wsa:MessageID>uuid:$uuid</wsa:MessageID><ActivityId CorrelationId="c2fa49e7-fb82-41fe-81d3-065e985a3df6" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">cbe1563c-0609-40dd-aa81-3ddcbebb0424</ActivityId><wsa:ReplyTo><wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address></wsa:ReplyTo><wsa:To soap:mustUnderstand="1">http://test.ceidg.gov.pl/CEIDG.Services.Import/RestrictionImport.svc</wsa:To>
        </soap:Header>
          <soap:Body>
              <tem:AddFileToImport>
                 <tem:fileName>?</tem:fileName>
                 <tem:importData>cid:1388108976858</tem:importData>
              </tem:AddFileToImport>
          </soap:Body>
        </soap:Envelope>""")

但是我收到了错误:

  

wslite.soap.SOAPFaultException:s:Sender - 由于EndpointDispatcher上的AddressFilter不匹配,无法在接收方处理带有To'http://test.ceidg.gov.pl/CEIDG.Services.Import/RestrictionImport.svc'的消息。检查发件人和收件人的EndpointAddresses是否同意

有什么想法吗?

0 个答案:

没有答案