Я хочу получить результат от SOAP.Но я не могу аутентифицироваться с заголовком системы.Я пробую много примеров и кодов.Но не сработало.
POST /Api/b2bservice.asmx HTTP/1.1 Host: b2b.servicewebsite.com Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://tempuri.org/getProductList" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <AuthHeader xmlns="http://tempuri.org/"> <Username>string</Username> <Password>string</Password> </AuthHeader> </soap:Header> <soap:Body> <getProductList xmlns="http://tempuri.org/" /> </soap:Body> </soap:Envelope>
Я написал так.Но я не могу получить результаты.Я хочу аутентифицироваться и вызывать функцию getProductList.
$username = 'username'; $password = 'n2eAwUNa'; $soapURL = "http://b2b.mywebsite.com/Api/b2bservice.asmx?wsdl"; $client = new SoapClient($soapURL,array()); $auth = array( 'Username' => $username, 'Password' => $password ); $header = new SoapHeader('http://b2b.mywebsite.com/Api/b2bservice.asmx','AuthHeader',$auth,false); echo $client->__setSoapHeaders($header); echo "<hr/>"; /* Requesting function list (interface) from SOAP server */ echo var_dump($functions = $client->__getFunctions()); echo "<hr/>"; echo var_dump($types = $client->__getTypes()); var_dump($functions); echo "<hr/>"; $products = $client->getProductList(); echo var_dump($products);