我使用PHP连接到Web Service。
我需要使用一些登录详细信息连接到Web服务,这样我就可以生成一个Ticket来开始使用可用的方法。
以下是一些代码:
//Connect To WebCrm API
$client = new SoapClient("http://b2b-email.net/apicrm1/webCRMAPI.asmx?wsdl", array('trace' => 1));
//Login
$ticket = $client->Authenticate(array('code' => 'rhgkhgk','user' =>'myusername','password' =>'apass'));
在响应soap标题中,将生成一个票证。这是在Ticket Header Then GUID下生成的。 (见下文)
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<TicketHeader xmlns="http://www.webcrm.com/">
<Guid>TICKET->>>>>>>>e446373e-8fg0-4dfc-b876-41f3bc8990dd</Guid>
</TicketHeader>
</soap:Header>
<soap:Body>
<AuthenticateResponse xmlns="http://www.webcrm.com/">
<AuthenticateResult>
<Message />
<Code>0</Code>
</AuthenticateResult>
</AuthenticateResponse>
</soap:Body>
</soap:Envelope>
我需要此票证ID才能使用Web服务执行任何其他任务,但如何访问它并在我的代码中使用它?
我尝试过使用以下内容:
$response = $client->__getLastResponse();
但是输出如下:
6d5933d3-46ff-4690-893d-2af04806668c->>>>>>>>0<<<<<ZERO ON THE END
当它不应该是零时总是在最后?
我们非常感谢您为什么能够以最佳方式从Soap Header访问门票的任何帮助!
答案 0 :(得分:0)
根据manual:
$soapclient->__soapCall("soapmethod", array(parameters), null, $input_headers, &$output_headers);
然后,