PHP soapClient send custom XML

后端 未结 2 509
旧巷少年郎
旧巷少年郎 2021-01-05 20:48

I\'m trying to make a SOAP request using soapClient class from PHP that\'s my code:

$xmlstr = <<

        
2条回答
  •  情深已故
    2021-01-05 20:56

    // xml post structure
            $xml_post_string = '
                                
                                      
                                        
                                          username
                                          password
                                        
                                      
                                      
                                        
                                      
                                    ';   
               $headers = array(
                            "Content-type: text/xml;charset=\"utf-8\"",
                            "Accept: text/xml",
                            "Cache-Control: no-cache",
                            "Pragma: no-cache",
                            "SOAPAction:http://tempuri.org/webservice_method_name", 
                            "Content-length: ".strlen($xml_post_string),
                        );
                $url =  "http://yourwebserviceurl.com/servicename.asmx";
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_TIMEOUT, 10);
                curl_setopt($ch, CURLOPT_POST, true);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
                curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                $response = curl_exec($ch); 
                curl_close($ch);
    

    //$response showing XML Response

    how to parse soap response using php for that see following website

    https://vaja906programmingworld.wordpress.com/

提交回复
热议问题