为SOAP请求创建特定的信封



英语不是我的母语,所以请耐心等待。

我需要一个特定的信封来消耗网络服务,因为服务器管理员是非合作人员。现在我有点困惑,因为我不知道从哪里开始。

我需要报告一些信件和账单的状态,能够使用PHP来制作脚本,以在MySQL数据库中搜索信息以报告Trought Webservice。

管理员而不是向我发送带有" WSDL"配置的IP地址以制作PHP SOAP客户端,而是发送示例文本文件(XML类型(以制作一个信封。使用SOAPUI能够得到答案(错误答案,但仍然是答案(,但我正在尝试进行自动报告(使用CRON(,但我不知道如何从XML制作信封以使肥皂要报告。

示例信封如下:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.esb.comfenalcovalle.com.co/">
   <soapenv:Header/>
   <soapenv:Body>
      <ws:requestMessageOut>
         <ws:header>
            <ws:invokerDateTime>2017-05-05</ws:invokerDateTime>
            <ws:moduleId>ACTUALIZA_CORRESPONDENCIA</ws:moduleId>
            <ws:systemId></ws:systemId>
            <ws:messageId>ACTUALIZA_CORRESPONDENCIA|123456789</ws:messageId>
            <ws:logginData>
               <ws:sourceSystemId></ws:sourceSystemId>
               <ws:destinationSystemId></ws:destinationSystemId>
            </ws:logginData>
            <ws:destination>
               <ws:namespace>http://co/com/comfenalcovalle/esb/ws/BPSirapActualizaCorrespondencia</ws:namespace>
               <ws:name>BPSirapActualizaCorrespondencia</ws:name>
               <ws:operation>execute</ws:operation>
            </ws:destination>
            <ws:securityCredential>
               <ws:userName></ws:userName>
               <ws:userToken></ws:userToken>
            </ws:securityCredential>
            <ws:classification>
               <!--Zero or more repetitions:-->
               <ws:classification></ws:classification>
            </ws:classification>
         </ws:header>
         <ws:body>
            <ws:request>
             <BPSirapActualizaCorrespondenciaProcessRequest>
              <pividdocu>1075000000010907</pividdocu>
              <pinidesdo>25</pinidesdo>
              <pinidmoed></pinidmoed>
              <pivdireccion>CR 34-10 229</pivdireccion>
              <pivcodigoLeyMuni>76001</pivcodigoLeyMuni>
              <pivcodigoLeyDpto>76</pivcodigoLeyDpto>
              <pivnumeroGuia>574127725</pivnumeroGuia>
              <pivnumeroRemision>0102205-12</pivnumeroRemision>
              <pivguiaDigitalizada>iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNS4xIE1hY2ludG9zaCIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDowREMwRTAxRUU1RkQxMUU0QUFGMDlERUQ0Mzk5MEUyNSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDoyNkIwNUI1RUU1RkQxMUU0QUFGMDlERUQ0Mzk5MEUyNSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjB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hqpn+A4qCzPwxbnf4PUtoeFxK7QEZXl+GsgRbo7NorWjT0bA5fFggcaf7ulZEFGegJW7Jos/EICXsrVNu+Ca92BpKYAB+wy0apXcKwkh+VkGm7jsbUVP5tlDUUtJXj7wTE16HZJ1GlQ/Ysa824ttmzMx41qAXrdJTlGiYZEiKeu0asRruD9n7HTZDIlaebMFYWUm+7YXEyQOPJxjRG1ZHkYnnairKJB3YxmL8LN5xhSW3Dk6cMcGOV9RkA6lYpkA2LJFJZEya3rhMZTmmWCmxTy8t5p2yLBMLoIgMwBr/hayI7kYSz5Mruam6dusuUYZMtu0cy3nZ6XyQOq4lWw07/HKtJMYr0aNNZMv9724q+WVuvKn3/pymmdzhqYlw5CAkmwjVSXwM0nmLomyB+c2NvqnLnRzmFg1jbvKkJoU/x6Z3r4fCzdf/H3o6Invf0WAxjgkMf7S8Nlfy8bhYJ5FH1VB2SpFPFe5Ga8+X9mymiBXs3DTrop8jagQ3jz5Qxd8tO2eRf8KlmeOhWijhXBlSoWAuq2FLMBJuvHpRl9azQO2maNft11Fv22SoGJQSHJjw0sX4oEe0iegoaYI9dssLACroudBXr8vs9dv18DYjo6+EUw73ZwseflEO2zky2jja8vMtJhxx9jLDohu5caDRGUPaSNpLmlClAhIGWFdID3FBuyf/pH410TE/yB/CzAAZIXaj6vGZXwAAAAASUVORK5CYII=</pivguiaDigitalizada>
             </BPSirapActualizaCorrespondenciaProcessRequest>
            </ws:request>
         </ws:body>
      </ws:requestMessageOut>
   </soapenv:Body>
</soapenv:Envelope>

如果您将此代码复制到SOAPUI并将"端点"设置为:https://virtual.comfenalcovalle.com.co.co/esbtest/wschanneladapter ...您会收到我在谈论的错误答案。<<<<<<<<<<<<<</p>

我正在寻找一些链接,寻找答案:

如何从此XML中在PHP中生成肥皂请求?

https://www.wackybabs.net/2004/07/creating-a-web-service-and-wsdl-wsdl-using-nusoap/

如何在php

中创建SOAP XML请求

php soapclient:在肥皂中覆盖了多种复杂类型

如何使用PHP

使用肥皂包络和身体标签生成XML

----------------------> 5月18日更新

感谢Alex Blex的回答,使用他的观点将XML作为"字符串"可以使用解决方案来消耗Web服务,而不是配置客户端只需使用" null"。

$location_URL = 'https://virtual.comfenalcovalle.com.co/esbtest/WSChannelAdapter';
$action_URL = "https://virtual.comfenalcovalle.com.co/esbtest/WSChannelAdapter";
$client = new SoapClient(null, array(
'location' => $location_URL,
'uri'      => "https://virtual.comfenalcovalle.com.co/esbtest/WSChannelAdapter",
'trace'    => 1,
));
$return = $client->__doRequest($xmlString,$location_URL,$action_URL,1);

可悲的是,$返回也是一个字符串,而是一个对象或XML,因此获得报告并存储在数据库中是很重要的。

当我使用Alex Blex提出的方法时,没有收到任何东西,这是对他的代码的次要修改:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://virtual.comfenalcovalle.com.co/esbtest/WSChannelAdapter');
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $xmlstring );
$result = curl_exec($ch);
$info = curl_getinfo($ch);
$errors = curl_error($ch);
$resArr = array();
$resArr = json_decode($result);
$xml = simplexml_load_string($result);
echo "<pre>"; print_r($result); echo "</pre>";
echo "<pre>"; print_r($info); echo "</pre>";
echo "<pre>"; print_r($resArr); echo "</pre>";
echo "<pre>"; print_r($errors); echo "</pre>";
curl_close($ch);

我已经在工作客户,但是可以尽快实施任何更正或新方法。

您可以使用卷发。

如果您将XML发布到API,例如

curl --request POST 
  --url https://virtual.comfenalcovalle.com.co/esbtest/WSChannelAdapter 
  --data '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.esb.comfenalcovalle.com.co/"> .... </soapenv:Envelope>'

您实际上得到了成功的回复

    ....
    <NS1:responseMessageOut xmlns:NS1="http://ws.esb.comfenalcovalle.com.co/">
        <NS1:header>
            <NS1:invokerDateTime>2017-05-05</NS1:invokerDateTime>
            <NS1:moduleId>ACTUALIZA_CORRESPONDENCIA</NS1:moduleId>
            <NS1:systemId></NS1:systemId>
            <NS1:messageId>ACTUALIZA_CORRESPONDENCIA|123456789</NS1:messageId>
            <NS1:logginData>
                <NS1:sourceSystemId></NS1:sourceSystemId>
                <NS1:destinationSystemId></NS1:destinationSystemId>
            </NS1:logginData>
            <NS1:destination>
                <NS1:namespace>http://co/com/comfenalcovalle/esb/ws/BPSirapActualizaCorrespondencia</NS1:namespace>
                <NS1:name>BPSirapActualizaCorrespondencia</NS1:name>
                <NS1:operation>execute</NS1:operation>
            </NS1:destination>
            <NS1:responseStatus>
                <NS1:statusCode>SUCESS</NS1:statusCode>
            </NS1:responseStatus>
        </NS1:header>
        <NS1:body>
            <NS1:response>
                <BPSirapActualizaCorres
      ....

在PHP中,应该像

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://virtual.comfenalcovalle.com.co/esbtest/WSChannelAdapter');
    curl_setopt( $ch, CURLOPT_POST, true );
    curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch, CURLOPT_POSTFIELDS, $theXML );
    $result = curl_exec($ch);
    curl_close($ch);

$result中的响应可以用DOMXML或Simplexml解析。

相关内容

  • 没有找到相关文章

最新更新