Web服务编码对附件不正确

时间:2018-03-26 18:55:20

标签: c# web-services wcf wsdl mtom

我正在使用C#调用Java Web服务。该服务要求我发送附件和有效负载。

我从客户那里得到了什么: 1)WSDL和模式文件 2)两个证书

我最初使用SOAP UI发送请求只是为了看看我是否能让它工作。

以下是我使用的安全设置: enter image description here enter image description here

这是我看到使用SOAPUI发出的请求。注意我确实删除了一些附件,因为它有敏感信息。关键是附件 文字看起来很好。这意味着编码是正确的。

------=_Part_31_7314110.1522073646059
Content-Type: application/soap+xml; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-ID: <rootpart@soapui.org>

<soap:Envelope xmlns:int="http://xxxxxxx/" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header>
<wsse:Security 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:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="35E54383F815C57E721522073646058239">MIIGJTCCBQ2gAwIBAgIRAOI3mEvrFfiPB5xNWTFBMGswDQYJKoZIhvcNAQELBQAwgZYxCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNVBAcTB1NhbGZvcmQxGjAYBgNVBAoTEUNPTU9ETyBDQSBMaW1pdGVkMTwwOgYDVQQDEzNDT01PRE8gUlNBIE9yZ2FuaXphdGlvbiBWYWxpZGF0aW9uIFNlY3VyZSBTZXJ2ZXIgQ0EwHhcNMTcwMTMwMDAwMDAwWhcNMTkwMTMwMjM1OTU5WjCCAQExCzAJBgNVBAYTAlVTMQ4wDAYDVQQREwU5NTgxNDELMAkGA1UECBMCQ0ExEzARBgNVBAc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T0RPUlNBT3JnYW5pemF0aW9uVmFsaWRhdGlvblNlY3VyZVNlcnZlckNBLmNydDAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AuY29tb2RvY2EuY29tMD8GA1UdEQQ4MDaCF2Ntc3Byb3ZpZGVyLmNhaHduZXQuZ292ght3d3cuY21zcHJvdmlkZXIuY2Fod25ldC5nb3YwDQYJKoZIhvcNAQELBQADggEBAByJZY5kfeo6TmYjcn0Afsl2WokUKm6aQda1MmgfZAdFIxTFixiRfWdZVLTQ9Qi93Pili3Zz6sEadHWlQjhnGnnJTQlL31KUi22dqIENuFXGqNOouefscqbh1vimPTg7yub85dXxPZYCUafVQbxt4IADQ8WROQJAGPbjTXjJPPlclH/dB0tTjAdyzNcyLxXtUGMM9FmRp9W99VKQsoi1L/Byo7fvk1Mw6921g1Pi5zgrt19FGYD0pqSNOrFfjb5DZiID7XqWZ1Be5Ha0S+qwFySkHbwWZXKCfltEyfHPHx+gWec4kClouTs7TGY7oIyfoHIgBChiygSjVcAZCKO7WiU=</wsse:BinarySecurityToken><xenc:EncryptedKey Id="EK-35E54383F815C57E721522073646058238" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"><xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"/><ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><wsse:SecurityTokenReference><wsse:Reference URI="#35E54383F815C57E721522073646058239" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/></wsse:SecurityTokenReference></ds:KeyInfo><xenc:CipherData><xenc:CipherValue>D0QnFQINT+eM/UnVJE32kPF0lgCbhpmgsGK9A2clyADu7qnng89jq9QdegfTdRSxcGv9nWxFss1qGkvfB3iiF+Ux7+bexMuyDZdjSE0np3zBuwQ+3yN9/iAsJBBgqx9Bj0s+PnS0QgQbRUGkWsWUKMnkSHLirTFxjKV+LPJQRxJLLvcWj6fez8XlxJoUCDa/LJwDuMFtCv4rkfatLlzdNJGNWml51HZnwgZKDsBOwGKNzrJBnSaP6UCbE7nmPn5Qb3U6x8yfHRomGlFYHtqmURkFeUfllOlMYIWl6GOoLzDU6OarqHOwnIISVjfGwadKnCf2AdHfZ1WHeMxKhz44EA==</xenc:CipherValue></xenc:CipherData><xenc:ReferenceList><xenc:DataReference URI="#ED-35E54383F815C57E721522073646058240"/></xenc:ReferenceList></xenc:EncryptedKey><wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="X509-35E54383F815C57E721522073646023233">MIIF+TCCBOGgAwIBAgIQIWv3OdE866kXP/MQVRf4fjANBgkqhkiG9w0BAQsFADCBljELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxPDA6BgNVBAMTM0NPTU9ETyBSU0EgT3JnYW5pemF0aW9uIFZhbGlkYXRpb24gU2VjdXJlIFNlcnZlciBDQTAeFw0xODAxMDMwMDAwMDBaFw0yMTAxMDIyMzU5NTlaMIHVMQswCQYDVQQGEwJVUzEOMAwGA1UEERMFOTQ2MTIxCzAJBgNVBAgTAkNBMRAwDgYDVQQHEwdPYWtsYW5kMRcwFQYDVQQJEw4xIEthaXNlciBQbGF6YTEsMCoGA1UEChMjS2Fpc2VyIEZvdW5kYXRpb24gSGVhbHRoIFBsYW4sIEluYy4xDTALBgNVBAsTBEtQSVQxGTAXBgNVBAsTEE11bHRpLURvbWFpbiBTU0wxJjAkBgNVBAMTHWNucGRjbnYwMjQzMi5kY2xkLnBsZGMua3Aub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqQ3uaJLeAueQJz8GvaCmQiql22cIa4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73DjowTsOrFXM7/se71nGRVzKBHdjomvA6MO1OIosLxw1aweH071kz29NZT2ZX0d5khFVHXf2kGu0aq9DK7qNEEx6jG713m265+lZIlozjF6hpuaCLPmPBJdaoLZq0nZ7MmGcslNdVkgiUuicEkUFAzuIM7uwTbuJCka30r03+qmxfYi0BIBcST08JB6dnfnjAZrSRXXSmuIBTei76XRjWTvKsE3yIGJShvRYSQWHthumQJ3+lV30k9rJ6bF2nByqhdO1mr1eod9u4ndl8vnxuGfv0j9Nqc+H5yPb4VNHt</wsse:BinarySecurityToken><ds:Signature Id="SIG-35E54383F815C57E721522073646024237" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><ec:InclusiveNamespaces PrefixList="int soap" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/></ds:CanonicalizationMethod><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><ds:Reference URI="#id-35E54383F815C57E721522073646023236"><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><ec:InclusiveNamespaces PrefixList="int" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue>Gv8GU/vT1h3OUZMB7Lvgj3CxEjU=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>ZChgeB6dnMAW99qhwHZw8Dwb8QjRMGwIY++qXDlK9UqpMISuuLL4vkoc+31tFj3rHTsFxHJftxfdaRzyCZce2V0ioatFiw5S6hI/cyhnLVxZJK80MOx3xyYK1oT+I4DO1gTvs9v9pEK/V//qMMVV4avRaO0bFuJaW0C1X06zUj5oz/xH1XdCYSuvSMmC+dammY+b/2XXofP+JM9FRx/l5+v1hhbv+6tiC/xAmKe62Ywvw5rblw/0QzFEXOwTiUUiKFM1d5Ie0s1HQwcW1kKCpaS6oiQB+bU6Dgxg9KeSlrkTo6cuSuJ6Hn7Pe1nqCTq76saZsxJRw3PISD/4Ih8BAg==</ds:SignatureValue><ds:KeyInfo Id="KI-35E54383F815C57E721522073646023234"><wsse:SecurityTokenReference wsu:Id="STR-35E54383F815C57E721522073646023235"><wsse:Reference URI="#X509-35E54383F815C57E721522073646023233" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/></wsse:SecurityTokenReference></ds:KeyInfo></ds:Signature></wsse:Security></soap:Header>
<soap:Body wsu:Id="id-35E54383F815C57E721522073646023236" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><xenc:EncryptedData Id="ED-35E54383F815C57E721522073646058240" Type="http://www.w3.org/2001/04/xmlenc#Content" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"><xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/><ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><wsse:SecurityTokenReference wsse11:TokenType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsse11="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd"><wsse:Reference URI="#EK-35E54383F815C57E721522073646058238"/></wsse:SecurityTokenReference></ds:KeyInfo><xenc:CipherData><xenc:CipherValue>pf35DvcRZ/yADZnUn+uvs+zvZ0O3YxgEOcol1pf0FVssYse0xl4h879jNqEg86WEo0b2JIIwkHII9V9RIJK/HC3Yzr/wucecUH/c5b7a6PAjdE5pGaH2mx1Be0tEz9tBdffCq7ms5vqU84UnWpPIcJiv/hka2dgkwUMYZR+9ct9QF0QcDNA+/4gJXGbTWxguGl9tvv3aD8xdZYIFH0OiZn0N1E2omYrO3fuoR0Bx2ZrqMywe6xgtHmKfXlpX8695wvYDdD1JVsniO92oUIeapgLCCIaMOjHHmDT3aPLH9muyyneJBTAv3bvOaLMu2Q8ZsiJnfoZYmrwApR9iIdv+rwRaQZEaAkMoj5rD0a28aXEbilTquv5my1XVlSUjLIUbgbQFxEANARVDfC7vz8XOKjwfrrYijPX4XkLOyO2/36OUekQxKCyH7Cwf2jG5vp9+rdxySo2+vMYM8s+LoPgydwMk7/Z0V7DKWE9+XrxF4P/BJgVCo9it8NCXC4kLsGpnns22irUUPk3puo6uV/BpMJ3qNLnrjg+i8rtDJY0DUhQRHTFAcuf2HiVZP4YHrrhvIXLmfR4rDyK180H+0gIvVtErdszQQSeBhMnSzDJMpOGTxOAhyqx59ygcDW3H5artE0rdGwtCp8fc+sr22oP+7pj2w3+LeuwcJWqVv/8isvrVEg1GqVU8l/B+JsbnRzInCXVXucsIGzMyyCBgqapQg853U5D2dLCN9yeh86dJcOc=</xenc:CipherValue></xenc:CipherData></xenc:EncryptedData></soap:Body>
</soap:Envelope>
------=_Part_31_7314110.1522073646059
Content-Type: text/plain; charset=us-ascii; name=attachment.txt
Content-Transfer-Encoding: 7bit
Content-ID: <attachment.txt>
Content-Disposition: attachment; name="attachment.txt"; filename="attachment.txt"

ISA
GS
ST
BHT
HL
NM1
HL
NM1
REF

然后我使用C#创建代理类,使用&#34;添加服务引用&#34;我只是从我的本地硬盘驱动器给了他WSDL的路径,它为我的项目添加了服务引用。

以下是我的app.config设置:

<system.serviceModel>
    <diagnostics>
      <messageLogging
           logEntireMessage="true"
           logMalformedMessages="false"
           logMessagesAtServiceLevel="true"
           logMessagesAtTransportLevel="false"
           maxMessagesToLog="3000"
           maxSizeOfMessageToLog="2000"/>
    </diagnostics>
    <client>
      <endpoint address="https://xxxxxxxxx/CORETransactionService"
        behaviorConfiguration="endpointCredentialBehavior" binding="customBinding"
        bindingConfiguration="esar" contract="ESAR.CORETransaction"
        name="CoreSoapPort" />
    </client>
   <behaviors>
     <endpointBehaviors>  
        <behavior name="endpointCredentialBehavior"> 
          <clientCredentials>  
            <clientCertificate findValue="xxxxxx"
                               storeLocation="CurrentUser"
                               storeName="My"
                               x509FindType="FindBySubjectName"/>

           <serviceCertificate>
              <defaultCertificate findValue="xxxxxxx"
                               storeLocation="CurrentUser"
                               storeName="AddressBook"
                               x509FindType="FindBySubjectName" />   
           </serviceCertificate>
          </clientCredentials>  
        </behavior>  
     </endpointBehaviors>  
  </behaviors>
    <bindings>
      <customBinding>
        <binding name="esar">
          <security authenticationMode="CertificateOverTransport" requireDerivedKeys="false"
            includeTimestamp="true" messageProtectionOrder="EncryptBeforeSign"
            messageSecurityVersion="WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10" />
          <mtomMessageEncoding messageVersion="Soap12" writeEncoding="utf-8" />
          <httpsTransport />
        </binding>
      </customBinding>
    </bindings>

</system.serviceModel> 

我从fiddler看到的.NET代码请求:

POST https://xxxxxx/ESARWS/CORETransactionService HTTP/1.1
MIME-Version: 1.0
Content-Type: multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:e4b740c0-385c-4059-ae61-0875593cac29+id=1";start-info="application/soap+xml"; action="http://xxxxxxx/CORETransaction/COREEnvelopeBatchSubmissionRequest"
Host: xxxxxxx
Content-Length: 4867
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive


--uuid:e4b740c0-385c-4059-ae61-0875593cac29+id=1
Content-ID: <http://tempuri.org/0>
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="application/soap+xml"

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><s:Header><VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPo58SbPhu/LxLohlN/KZf5u8AAAAAXm+DfOpqZk+LU88+m3lwcfV2Z+cnONZIgM5HRyfLVZMACQAA</VsDebuggerCausalityData><o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><u:Timestamp u:Id="_0"><u:Created>2018-03-26T18:30:46.472Z</u:Created><u:Expires>2018-03-26T18:35:46.472Z</u:Expires></u:Timestamp><o:BinarySecurityToken u:Id="uuid-1d696b47-6513-4ec1-8f92-1392a2dcb18a-1" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"><xop:Include href="cid:http://tempuri.org/1/636576606465882504" xmlns:xop="http://www.w3.org/2004/08/xop/include"/></o:BinarySecurityToken><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><Reference URI="#_0"><Transforms><Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>fh88aYsyizCd5ytsDwNqA3W+2k0=</DigestValue></Reference></SignedInfo><SignatureValue>eri1Ez48L+MLaf4NKhjMKdt+XwoaTmG+6ZJm9dKFEmaHWQUInM/mfY5QFpyYrfUSKWrauU54V4GjgBU8Uzjhxb24Ejk7jJKmVE+mobvsC6b2o7RI4Cy7i1cv7RuZdzTdBewBlZ7MrzdCaHXVxcnpuEw4KzdaiN9iC39AbzWGpKF2A5DjNz36FsTKs4NNsQZ4DZW0V8uwwZv6ocHyWmBMhGc+XMGbxqRpfGdOW4BvaRahc9DxUcejbNJdBYptwkYYrDbFu6ZtvJFbMSJQOFxHKDlP0N9EDmgov6cDqF9tnKixG5KyfEAyz0jQxjOnv91mVcyUkCCJkztSudBtOGmg/A==</SignatureValue><KeyInfo><o:SecurityTokenReference><o:Reference ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" URI="#uuid-1d696b47-6513-4ec1-8f92-1392a2dcb18a-1"/></o:SecurityTokenReference></KeyInfo></Signature></o:Security></s:Header><s:Body><COREEnvelopeBatchSubmission xmlns="http://xxxxxxx/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><PayloadType xmlns="">X12_278_Request_005010X217E1_2</PayloadType><ProcessingMode xmlns="">Batch</ProcessingMode><PayloadID xmlns="">2d62e838-8a78-4c4d-8095-7e40297edf36</PayloadID><PayloadLength xmlns="">820</PayloadLength><TimeStamp xmlns="">2018-03-26 11:30:44Z</TimeStamp><SenderID xmlns="">CMS1P00183</SenderID><ReceiverID xmlns="">DHCS CMS NET</ReceiverID><CORERuleVersion xmlns="">4.0.0</CORERuleVersion><CheckSum xmlns="">95-6C-F3-8B-72-3F-34-3C-5D-2E-DD-7B-51-8D-47-1A-0F-70-48-41</CheckSum><Payload xmlns="">cid:11111111</Payload></COREEnvelopeBatchSubmission></s:Body></s:Envelope>
--uuid:e4b740c0-385c-4059-ae61-0875593cac29+id=1
Content-ID: <http://tempuri.org/1/636576606465882504>
Content-Transfer-Encoding: binary
Content-Type: application/octet-stream

0  0  !k 9 < ? U ~0
    * H  

 0  1
0   UGB10UGreater Manchester10U  Salford10U
COMODO CA Limited1<0:U3COMODO RSA Organization Validation Secure Server CA0
180103000000Z
210102235959Z0  1
0   UUS10U946121
0   Uxx10U  xxxx10U 1 xxxx1,0*U
#xxxxxxx, Inc.1
0
U
KPIT10U
Multi-Domain SSL1&0$Ucnpdcnv02432.dcld.pldc.kp.org0 "0
    * H  
   0 

 h   '?   B*  gk u F  UWsl2   q n  n z<   s 륟y ) Ɲ $  QV_ G7R'   yKHJ)  x  'Wa Q< E%   |T #=  + c8 R>     JV8  ZQ mVb  R    \z
  >@_ ˁ ?ߍx 
   K^ 
6 0    Z
/Uy  : 01 ى:  ? _<g Kط c j [ ě-      ė2O c  g\- #yuk 0< : \ /V8 t     0  0U#0   + ϭO / *HH* B $0U \  
 i 0䴓E [*  0U  0U 0 0U%0+ + 0PU I0G0;+ 10+0)+ https://xxxxx/CPS0g 0ZUS0Q0O M K Ihttp://xxxxx/COMODORSAOrganizationValidationSecureServerCA.crl0  + 0}0U+ 0 Ihttp://xxxx/COMODORSAOrganizationValidationSecureServerCA.crt0$+ 0 http://ocsp.comodoca.com0AU:08 cnpdcnv02432.dcld.pldc.kp.org ccsncal-dev.appl.kp.org0
    * H  

   @ Ⱦ    U  sVZ Pm ZÈ(  | H n1 :0Nës; ǻ q W2    :0 N" 

Z    Y3  YOfW  d UG]       D  w n  VH    i   >c %֨-    ̘g,  U   ' A@    n B   M  l_b- OO      g~x f  ]t   Sz. ] N |    Aa  ' W}$  zl]  * t f W w۸  | |n   js     T  
--uuid:e4b740c0-385c-4059-ae61-0875593cac29+id=1--

所以我收到400 Bad Request。正如您首先看到的那样,附件未正确编码。我认为这就是400 Bad Request的原因。

我的问题如何更改此内容(来自我的.NET请求)

Content-ID: <http://tempuri.org/1/636576606465882504>
Content-Transfer-Encoding: binary
Content-Type: application/octet-stream

到此(来自SOAPUI请求)???

Content-Type: text/plain; charset=us-ascii; name=attachment.txt
Content-Transfer-Encoding: 7bit
Content-ID: <attachment.txt>
Content-Disposition: attachment; name="attachment.txt"; filename="attachment.txt"

这是我的WSDL文件

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="CORETransactionService" targetNamespace="http://xxxxxxxxx/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:tns="xxxxxxxxx" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata">
  <types>
    <xsd:schema>
      <xsd:import namespace="http://xxxxxxxxxx/" schemaLocation="CORETransactionService_schema1.xsd"/>
    </xsd:schema>
  </types>
  <message name="COREEnvelopeBatchSubmission">
    <part name="parameters" element="tns:COREEnvelopeBatchSubmission">
    </part>
  </message>
  <message name="COREEnvelopeBatchSubmissionAckRetrievalRequestResponse">
    <part name="parameters" element="tns:COREEnvelopeBatchSubmissionAckRetrievalRequestResponse">
    </part>
  </message>
  <message name="COREEnvelopeBatchResultsAckSubmission">
    <part name="parameters" element="tns:COREEnvelopeBatchResultsAckSubmission">
    </part>
  </message>
  <message name="COREEnvelopeBatchResultsRetrievalRequest">
    <part name="parameters" element="tns:COREEnvelopeBatchResultsRetrievalRequest">
    </part>
  </message>
  <message name="COREEnvelopeBatchSubmissionResponse">
    <part name="parameters" element="tns:COREEnvelopeBatchSubmissionResponse">
    </part>
  </message>
  <message name="COREEnvelopeBatchResultsRetrievalRequestResponse">
    <part name="parameters" element="tns:COREEnvelopeBatchResultsRetrievalRequestResponse">
    </part>
  </message>
  <message name="COREEnvelopeBatchResultsAckSubmissionResponse">
    <part name="parameters" element="tns:COREEnvelopeBatchResultsAckSubmissionResponse">
    </part>
  </message>
  <message name="COREEnvelopeBatchSubmissionAckRetrievalRequest">
    <part name="parameters" element="tns:COREEnvelopeBatchSubmissionAckRetrievalRequest">
    </part>
  </message>
  <portType name="CORETransaction">
    <operation name="COREEnvelopeBatchSubmission">
      <input message="tns:COREEnvelopeBatchSubmission" wsam:Action="http://xxxxxxxx/CORETransaction/COREEnvelopeBatchSubmissionRequest">
    </input>
      <output message="tns:COREEnvelopeBatchSubmissionResponse" wsam:Action="http://xxxxxxxx/CORETransaction/COREEnvelopeBatchSubmissionResponse">
    </output>
    </operation>
    <operation name="COREEnvelopeBatchResultsRetrievalRequest">
      <input message="tns:COREEnvelopeBatchResultsRetrievalRequest" wsam:Action="http://xxxxxxxx/CORETransaction/COREEnvelopeBatchResultsRetrievalRequestRequest">
    </input>
      <output message="tns:COREEnvelopeBatchResultsRetrievalRequestResponse" wsam:Action="http://xxxxxxxx/CORETransaction/COREEnvelopeBatchResultsRetrievalRequestResponse">
    </output>
    </operation>
    <operation name="COREEnvelopeBatchSubmissionAckRetrievalRequest">
      <input message="tns:COREEnvelopeBatchSubmissionAckRetrievalRequest" wsam:Action="http://xxxxxxxx/CORETransaction/COREEnvelopeBatchSubmissionAckRetrievalRequestRequest">
    </input>
      <output message="tns:COREEnvelopeBatchSubmissionAckRetrievalRequestResponse" wsam:Action="http://xxxxxxxx/CORETransaction/COREEnvelopeBatchSubmissionAckRetrievalRequestResponse">
    </output>
    </operation>
    <operation name="COREEnvelopeBatchResultsAckSubmission">
      <input message="tns:COREEnvelopeBatchResultsAckSubmission" wsam:Action="http://xxxxxxxx/CORETransaction/COREEnvelopeBatchResultsAckSubmissionRequest">
    </input>
      <output message="tns:COREEnvelopeBatchResultsAckSubmissionResponse" wsam:Action="http://xxxxxxxx/CORETransaction/COREEnvelopeBatchResultsAckSubmissionResponse">
    </output>
    </operation>
  </portType>
  <binding name="CoreSoapPortBinding" type="tns:CORETransaction">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsp:PolicyReference URI="#wsp-d022643e-c1aa-467f-8471-f28e404d63fb"/>
    <operation name="COREEnvelopeBatchSubmission">
      <soap:operation soapAction=""/>
      <input>
        <soap:body use="literal"/>
    <wsp:PolicyReference URI="#wsp-36c7d205-214b-495a-a9e6-7408702f5552"/>
      </input>
      <output>
        <soap:body use="literal"/>
    <wsp:PolicyReference URI="#wsp-f8978c59-3217-43f9-820a-8c3e3e3feb0c"/>
      </output>
    </operation>
    <operation name="COREEnvelopeBatchResultsRetrievalRequest">
      <soap:operation soapAction=""/>
      <input>
        <soap:body use="literal"/>
    <wsp:PolicyReference URI="#wsp-bf44b4a7-73d8-4606-a17a-d7917de2af14"/>
      </input>
      <output>
        <soap:body use="literal"/>
    <wsp:PolicyReference URI="#wsp-d352ae97-370a-492e-9852-f5d2a4d2ef61"/>
      </output>
    </operation>
    <operation name="COREEnvelopeBatchSubmissionAckRetrievalRequest">
      <soap:operation soapAction=""/>
      <input>
        <soap:body use="literal"/>
    <wsp:PolicyReference URI="#wsp-2afe23fd-9e1b-492d-9422-d5cdf8c68d7a"/>
      </input>
      <output>
        <soap:body use="literal"/>
    <wsp:PolicyReference URI="#wsp-6c360abb-1d2b-46f6-aac1-b971a19c4b9e"/>
      </output>
    </operation>
    <operation name="COREEnvelopeBatchResultsAckSubmission">
      <soap:operation soapAction=""/>
      <input>
        <soap:body use="literal"/>
    <wsp:PolicyReference URI="#wsp-d5858019-4f16-48a8-aaf9-cb34f2a0aa43"/>
      </input>
      <output>
        <soap:body use="literal"/>
    <wsp:PolicyReference URI="#wsp-5c7caead-24e0-4ba8-882a-86cd6f3aeb3a"/>
      </output>
    </operation>
  </binding>
  <service name="CORETransactionService">
    <port name="CoreSoapPort" binding="tns:CoreSoapPortBinding">
      <soap:address location="http://XXXXXXXXXxxxxxxxxxxx"/>
    </port>
  </service>
    <wsp:Policy wsu:Id="wsp-d022643e-c1aa-467f-8471-f28e404d63fb"><ns2:AsymmetricBinding xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"><wsp:Policy><ns2:InitiatorToken><wsp:Policy><ns2:X509Token ns2:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient"><wsp:Policy><ns2:WssX509V3Token10/></wsp:Policy></ns2:X509Token></wsp:Policy></ns2:InitiatorToken><ns2:AlgorithmSuite><wsp:Policy><ns2:STRTransform10/><ns2:Basic128/></wsp:Policy></ns2:AlgorithmSuite><ns2:RecipientToken><wsp:Policy><ns2:X509Token ns2:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToInitiator"><wsp:Policy><ns2:WssX509V3Token10/></wsp:Policy></ns2:X509Token></wsp:Policy></ns2:RecipientToken><ns2:Layout><wsp:Policy><ns2:Strict/></wsp:Policy></ns2:Layout></wsp:Policy></ns2:AsymmetricBinding><ns2:Wss11 xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"><wsp:Policy><ns2:RequireSignatureConfirmation/></wsp:Policy></ns2:Wss11></wsp:Policy>
    <wsp:Policy wsu:Id="wsp-bf44b4a7-73d8-4606-a17a-d7917de2af14"><ns2:EncryptedParts xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"><ns2:Body/></ns2:EncryptedParts><ns2:SignedParts xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"><ns2:Body/></ns2:SignedParts></wsp:Policy>
    <wsp:Policy wsu:Id="wsp-d352ae97-370a-492e-9852-f5d2a4d2ef61"><ns2:EncryptedParts xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"><ns2:Body/></ns2:EncryptedParts><ns2:SignedParts xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"><ns2:Body/></ns2:SignedParts></wsp:Policy>
    <wsp:Policy wsu:Id="wsp-36c7d205-214b-495a-a9e6-7408702f5552"><ns2:EncryptedParts xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"><ns2:Body/></ns2:EncryptedParts><ns2:SignedParts xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"><ns2:Body/></ns2:SignedParts></wsp:Policy>
    <wsp:Policy wsu:Id="wsp-f8978c59-3217-43f9-820a-8c3e3e3feb0c"><ns2:EncryptedParts xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"><ns2:Body/></ns2:EncryptedParts><ns2:SignedParts xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"><ns2:Body/></ns2:SignedParts></wsp:Policy>
    <wsp:Policy wsu:Id="wsp-2afe23fd-9e1b-492d-9422-d5cdf8c68d7a"><ns2:EncryptedParts xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"><ns2:Body/></ns2:EncryptedParts><ns2:SignedParts xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"><ns2:Body/></ns2:SignedParts></wsp:Policy>
    <wsp:Policy wsu:Id="wsp-6c360abb-1d2b-46f6-aac1-b971a19c4b9e"><ns2:EncryptedParts xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"><ns2:Body/></ns2:EncryptedParts><ns2:SignedParts xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"><ns2:Body/></ns2:SignedParts></wsp:Policy>
    <wsp:Policy wsu:Id="wsp-d5858019-4f16-48a8-aaf9-cb34f2a0aa43"><ns2:EncryptedParts xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"><ns2:Body/></ns2:EncryptedParts><ns2:SignedParts xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"><ns2:Body/></ns2:SignedParts></wsp:Policy>
    <wsp:Policy wsu:Id="wsp-5c7caead-24e0-4ba8-882a-86cd6f3aeb3a"><ns2:EncryptedParts xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"><ns2:Body/></ns2:EncryptedParts><ns2:SignedParts xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"><ns2:Body/></ns2:SignedParts></wsp:Policy>
</definitions>

以下是我调用的代理文件中的签名方法: enter image description here

更新: 所以我开始考虑在.NET代码中作为二进制文件发送的附件是否真的是问题。

在SOAP UI中: 1)我附加了.NET从fiddler生成的编码字符串,并将内容类型设置为application / octet-stream。

结果是我得到了一条成功的消息。所以我猜这意味着问题不是附件是二进制或文本。我现在唯一的猜测是它仍然存在安全问题。

0 个答案:

没有答案