dongtiaozhou4914 2017-11-13 11:48
浏览 57
已采纳

Php提出肥皂要求

I trying to make soap request to Amadeus Web Service. I have xml file with soap-header

<?xml version="1.0"?>
<soap:Header xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <add:MessageID xmlns:add="http://www.w3.org/2005/08/addressing">dbbb6ca5-e5d4-7518-d84-f6f7c22ed752</add:MessageID>
  <add:Action xmlns:add="http://www.w3.org/2005/08/addressing">http://webservices.amadeus.com/Hotel_MultiSingleAvailability_10.0</add:Action>
  <add:To xmlns:add="http://www.w3.org/2005/08/addressing">https://nodeD1.test.webservices.amadeus.com/1ASIWOTANA8</add:To>
  <link:TransactionFlowLink xmlns:link="http://wsdl.amadeus.com/2010/06/ws/Link_v1"/>
  <oas:Security xmlns:oas="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
    <oas:UsernameToken xmlns:oas1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" oas1:Id="UsernameToken-1">
      <oas:Username>WSNA8OTA</oas:Username>
      <oas:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"nonce</oas:Nonce>
      <oas:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">pass</oas:Password>
      <oas1:Created>2017-11-09T08:50:40.588Z</oas1:Created>
    </oas:UsernameToken>
  </oas:Security>
  <AMA_SecurityHostedUser xmlns="http://xml.amadeus.com/2010/06/Security_v1">
    <UserID POS_Type="1" PseudoCityCode="MIA1S38BL" AgentDutyCode="SU" RequestorType="U"/>
  </AMA_SecurityHostedUser>
</soap:Header>

My php code

$params = [
            'exceptions' => 0,
            'soap_version' => SOAP_1_2,
            'trace' => 1,
        ];

        $soapvar = new \SoapVar($soapRequest, XSD_ANYXML);
        $client = new SoapClient($wsdlFile", $params);
        $result = $client->Hotel_MultiSingleAvailability($soapvar);

But if I print last request I get another xml

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://www.opentravel.org/OTA/2003/05">
  <env:Body>
    <soap:Header xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <add:MessageID xmlns:add="http://www.w3.org/2005/08/addressing">be4b7f20-c867-11e7-a815-83f383e012a5</add:MessageID>
      <add:Action xmlns:add="http://www.w3.org/2005/08/addressing">http://webservices.amadeus.com/Hotel_MultiSingleAvailability_10.0</add:Action>
      <add:To xmlns:add="http://www.w3.org/2005/08/addressing">https://nodeD1.test.webservices.amadeus.com/1ASIWOTANA8</add:To>
      <link:TransactionFlowLink xmlns:link="http://wsdl.amadeus.com/2010/06/ws/Link_v1"/>
      <oas:Security xmlns:oas="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
        <oas:UsernameToken xmlns:oas1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" oas1:Id="UsernameToken-1">
          <oas:Username>WSNA8OTA</oas:Username>
          <oas:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">nonce</oas:Nonce>
          <oas:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">pass</oas:Password>
          <oas1:Created>2017-11-13T11:42:35:788Z</oas1:Created>
        </oas:UsernameToken>
      </oas:Security>
      <AMA_SecurityHostedUser xmlns="http://xml.amadeus.com/2010/06/Security_v1">
        <UserID POS_Type="1" PseudoCityCode="MIA1S38BL" AgentDutyCode="SU" RequestorType="U"/>
      </AMA_SecurityHostedUser>
    </soap:Header>
  </env:Body>
</env:Envelope>

How I can remove env:body and env:envelope from my request and use only my xml file?

  • 写回答

2条回答 默认 最新

  • dongquanlin1885 2017-11-13 13:36
    关注

    To get soap:Header with it's children elements

    // load full xml
    $xml = simplexml_load_string($s);
    // get all namespaces used  in doc by seting true and register soap for xpath
    $xml->registerXPathNamespace ('soap', $xml->getDocNamespaces(true)['soap']);
    // get the part you want
    $myxml = $xml->xpath('/env:Envelope/env:Body/soap:Header');
    

    demo

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题