How to build a correct SOAP request with PHP

后端 未结 2 615
温柔的废话
温柔的废话 2020-12-03 09:21

I need to format/build a request for this SOAP \"service\": http://api.notificationmessaging.com/NMSOAP/NotificationService?wsdl

Ideally I would like to use the nati

2条回答
  •  旧时难觅i
    2020-12-03 09:36

    "Is there a more direct approach where I could write the XML?"

    By using a SoapVar and setting the encode parameter of the constructor to XSD_ANYXML you can write the raw XML.

    There should be a way where the WSDL helps build the XML though.

    You could try something like this:

    $wsdl   = "http://api.notificationmessaging.com/NMSOAP/NotificationService?wsdl"; 
    $client = new SoapClient($wsdl, array(  'soap_version' => SOAP_1_1,
                                            'trace' => true,
                                          )); 
    try {
    
        $xml = '
                
                    
                        1
                        
                        
                        
                        
                        Our powerful algorithms already
                        found a matching profile that matches your criteria:
                        
    Celina72 
    ]]>
    FIRSTNAME john johnblum@flowerpower.com BdX7CqkmjSivyBgIcZoN4sPVLkx7FaXGiwsO 6464 985A8B992601985A 2008-12-12T00:00:00 NOTHING EMAIL
    '; $args = array(new SoapVar($xml, XSD_ANYXML)); $res = $client->__soapCall('sendObject', $args); return $res; } catch (SoapFault $e) { echo "Error: {$e}"; } echo "
    Last Request"; echo "
    ", htmlspecialchars($client->__getLastRequest()), "
    ";

提交回复
热议问题