用Curl PHP进行肥皂请求 [英] Soap requests with Curl PHP

查看:69
本文介绍了用Curl PHP进行肥皂请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用下面的soap格式和url使用Curl php发出Soap请求?我已经在线尝试了可用的解决方案,但都没有解决。

How can I make Soap request using Curl php by using below soap format and url? I have tried avaliable solutions online and none of them worked out.

$soap_request = '<?xml version="1.0" encoding="UTF-8"?>
        <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:alisonwsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
          <soap:Header>
            <credentials>
                <alisonOrgId>9ReXlYlpOThe24AWisE</alisonOrgId>
                <alisonOrgKey>C2owrOtRegikaroXaji</alisonOrgKey>
            </credentials>
          </soap:Header>
          <SOAP-ENV:Body>
            <q1:login xmlns:q1="urn:alisonwsdl">
                <email xsi:type="xsd:string">email</email>
                <firstname xsi:type="xsd:string">fname</firstname>
                <lastname xsi:type="xsd:string">lname</lastname>
                <city xsi:type="xsd:string">city</city>
                <country xsi:type="xsd:string">country</country>
                <external_id xsi:type="xsd:string"></external_id>
            </q1:login>
          </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>';

 Url
https://alison.com/api/service.php?wsdl


推荐答案

奋斗了一周之后,我在youtube https://www.youtube.com/watch?v=6V_myufS89A ,我能够成功地向API发送请求,请先阅读上面的xml格式继续我的解决方案

After struggling for a week I was able to find something in this tutorial here on youtube https://www.youtube.com/watch?v=6V_myufS89A and I was able to send requests to the API successifuly, first read my xml format above before continuing with my solution

     $options = array('trace'=> true, "exception" => 0);

    $client  = new \SoapClient('your url to wsdl',$options);

   //if you have Authorization parameters in your xml like mine above use SoapVar and SoapHeader as me below

    $params = new \stdClass();
    $params->alisonOrgId = 'value here';
    $params->alisonOrgKey = 'value here';

    $authentication_parameters = new \SoapVar($params,SOAP_ENC_OBJECT);

    $header = new \SoapHeader('your url to wsdl','credentials',$authentication_parameters);

    $client->__setSoapHeaders(array($header));


   print_r($client->__soapCall("Function here",'Function parameter here or left it as null if has no parameter'));

    //or call your function by

     print_r($client->yourFunction($function_parameters));

    }

希望这会帮助那些在肥皂方面苦苦挣扎的人包含身份验证信息

Hope this will help someone out there struggling with soap requests that contains authentication informations

这篇关于用Curl PHP进行肥皂请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆