加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

delphi – SOAPUI中的错误请求

发布时间:2020-12-15 09:47:09 所属栏目:大数据 来源:网络整理
导读:我正在尝试使用Delphi 2010和Indy来使用Web服务.要建立一个可用的SOAP流来与我的程序创建的SOAP流进行比较,我在SOAPUI中进行测试.我正在使用Web服务提供程序提供的SOAP流,它也匹配WSDL文件中指定的SOAP流.我从服务中收到HTTP 400(错误请求)错误. 从我在网上
我正在尝试使用Delphi 2010和Indy来使用Web服务.要建立一个可用的SOAP流来与我的程序创建的SOAP流进行比较,我在SOAPUI中进行测试.我正在使用Web服务提供程序提供的SOAP流,它也匹配WSDL文件中指定的SOAP流.我从服务中收到HTTP 400(错误请求)错误.

从我在网上找到的内容来看,似乎收到HTTP 400错误表明您的SOAP请求格式错误且Web服务无法读取.我已经使用XMLPad测试了我的SOAP流,并且XML看起来很好.我想这可能意味着某些东西与其架构要求不匹配.如果不希望以纯文本形式发送,我将首先检查密码的模式描述.我还应该检查什么以消除HTTP 400错误?

这是我的请求(更少的用户名和密码),如果有帮助:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" 
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" 
xmlns:xop="http://www.w3.org/2004/08/xop/include" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://wwww3.org/2001/XMLSchema-instance">
   <soap:Header>
      <wsa:Action>http://edd.ca.gov/SendTransmission</wsa:Action>
      <wsa:MessageID>urn:uuid:5aa788dc-86e1-448b-b085-2d2743cf9f26</wsa:MessageID>
      <wsa:ReplyTo>
         <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
      </wsa:ReplyTo>
      <wsa:To>http://fsettestversion.edd.ca.gov/fsetproxy/fsetservice.asmx</wsa:To>
      <wsse:Security soap:mustUnderstand="1">
         <wsse:UsernameToken wsu:Id="UsernameToken">
            <wsse:Username>#USERNAME#</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">O5QWht1bslLCX6KnlEypAA==</wsse:Nonce>
            <wsu:Created>2012-02-29T22:32:38.250Z</wsu:Created>
         </wsse:UsernameToken>
         <wsu:Timestamp wsu:Id="Timestamp-805a7373-335c-43b6-ba21-6596c4848dbf">
            <wsu:Created>2012-02-22T15:41:42Z</wsu:Created>
            <wsu:Expires>2012-02-22T15:46:42Z</wsu:Expires>
         </wsu:Timestamp>
      </wsse:Security>
   </soap:Header>
   <soap:Body>
      <SendTransmission xmlns="http://edd.ca.gov/">
         <SendTransmissionRequest xmlns="http://www.irs.gov/a2a/mef/MeFTransmitterServiceWse.xsd">
            <TransmissionDataList>
               <Count>1</Count>
               <TransmissionData>
                  <TransmissionId>123456789</TransmissionId>
                  <ElectronicPostmark>2012-02-22T07:41:42.2502206-08:00</ElectronicPostmark>
               </TransmissionData>
            </TransmissionDataList>
         </SendTransmissionRequest>
         <fileBytes>
            <xop:Include href="cid:1.634654933022658454@example.org"/>
         </fileBytes>
      </SendTransmission>
   </soap:Body>
</soap:Envelope>

解决方法

可能还有别的东西,但此刻,我怀疑wsse:UsernameToken.我在 http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0.pdf下载了这份文件,并在昨晚阅读.它用相当简单的语言写成,我觉得我理解它的含义,但它留下的问题比我原先提出的问题要小.本文档建议您使用以下格式的纯文本密码:

<S11:Envelope xmlns:S11="..." xmlns:wsse="...">
  <S11:Header>
  ...
    <wsse:Security>
      <wsse:UsernameToken>
        <wsse:Username>Zoe</wsse:Username>
        <wsse:Password>IloveDogs</wsse:Password>
      </wsse:UsernameToken>
    </wsse:Security>
  ...
  </S11:Header>
...
</S11:Envelope>

或者您可以使用密码摘要.它定义了一个密码摘要,如下所示:

Password_Digest = Base64 ( SHA-1 ( nonce + created + password ) )

根据参考资料,密码摘要的格式如下所示:

<S11:Envelope xmlns:S11="..." xmlns:wsse="..." xmlns:wsu= "...">
  <S11:Header>
  ...
  <wsse:Security>
    <wsse:UsernameToken>
      <wsse:Username>NNK</wsse:Username>
      <wsse:Password Type="...#PasswordDigest">
      weYI3nXd8LjMNVksCKFV8t3rgHh3Rw==
      </wsse:Password>
      <wsse:Nonce>WScqanjCEAC4mQoBE07sAQ==</wsse:Nonce>
      <wsu:Created>2003-07-16T01:24:32Z</wsu:Created>
    </wsse:UsernameToken>
  </wsse:Security>
  ...
  </S11:Header>
...
</S11:Envelope>

这不是Web服务发布者提供的示例中使用的格式.引用中的纯文本版本不使用随机数.示例消息使用nonce但调用纯文本密码.在我看来,使用没有密码摘要的随机数不会给消息增加任何安全性.如果没有关于如何创建它的协议,它可以是任何随机字符串.我错过了这一点吗?

我知道这看起来似乎是一项繁琐的工作,但我希望通过这里提供这个,也许我们可以为下一个人提供一些帮助.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读