PHP输入页面到SOAP

时间:2018-11-29 16:41:04

标签: php soap wsdl

我正在尝试制作一个简单的PHP页面,该页面需要一个输入字符串并将其发送到SOAP服务。

需要大量阅读,但无法正常工作。

我的input.php文件:

$soapClient = new SoapClient("https://cpsapi.tdc.dk/sendsmsservice?wsdl", array("trace" => 1, "exceptions" => 0,
                 "login" => "user123", "password" => "pass123") );



    // Prepare SoapHeader parameters 
    $sh_param = array( 
                "login" => 'user123', 
                "password" => 'pass123'
                ); 
    $headers = new SoapHeader('http://www.csapi.org/schema/parlayx/sms/send/v2_3/local', 'sendsms', $sh_param); 

    // Prepare Soap Client 
   $soapClient->__setSoapHeaders(array($headers)); 

    // Setup the RemoteFunction parameters 
    $ap_param = array( 
                'addresses' => $_REQUEST["nr"],
                'senderName' => "static", 
                'message' => $_REQUEST["besked"]);




    // Call RemoteFunction () 
    $error = 0; 



    try { 
        $info = $soapClient->__call("SendSms", array($ap_param)); 
        print("OK");
//    } catch (\Exception $e) { 
    } catch (SoapFault $fault) {
        $error = 1; 
//      throw new \Exception("Soup request failed! Response: ".$soapClient->__getLastResponse());
        print("Sorry, blah returned the following ERROR: ".$fault->faultcode." String: ".$fault->faultstring.". Text: "); 
    } 

生成的XML必须类似于:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:loc="http://www.csapi.org/schema/parlayx/sms/send/v2_3/local">

   <soapenv:Body>
       <loc:sendSms>
         <loc:addresses>xx-value of nr-xx</loc:addresses>
        
         <loc:senderName>static</loc:senderName>
         <loc:message>xx-value of besked-xx</loc:message>
    
</loc:sendSms>

   </soapenv:Body>
</soapenv:Envelope>

我通常使用VB Script和非常简单的PHP,因此使用这种“简单”的SOAP集成给我带来了麻烦

关于, 拉斯穆斯

0 个答案:

没有答案