Maybe anybody can help to build PHP soap request. Server is C++ API to accept query. I have request XML code that is correct, but little bit confused on how-to-do-it.
Here it is:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetSessionKey xmlns="http://tempuri.org/">
<request xmlns:a="http://schemas.datacontract.org/2004/07/Core.WcfExtenssions" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:MethodName i:nil="true"/>
<a:Password i:nil="true"/>
<a:RequestData xmlns:b="http://schemas.datacontract.org/2004/07/MotorServices.MotorDataTransferObjects.Args">
<b:Password>PASSWORD</b:Password>
<b:UserName>USERNAME</b:UserName>
</a:RequestData>
<a:RequestID>eb8b6fe8-2ef3-4b97-bf11-26a733e13158</a:RequestID>
<a:Timestamp>2013-04-19T12:35:50.395084+02:00</a:Timestamp>
<a:UserName i:nil="true"/>
</request>
</GetSessionKey>
</s:Body>
</s:Envelope>
This is my example how I did it. Simple code, but server retur fault "Object reference not set to an instance of an object".
try {
$ServiceClient = new SoapClient(URL,
array(
'trace' => 1,
'connection_timeout' => 20,
'timeout' => 20
));
$arguments = array(
'request' => array(
'RequestData' => array(
'Password' => PASS,
'UserName' => USER
)
)
);
$session = $ServiceClient->__soapCall("GetSessionKey", $arguments);
} catch (SoapFault $soapFault) {
var_dump($soapFault);
}
In C/C++ Login method look like code below. This method is used to login to service and acquire session key. I expected to create similar method, but I don't understand structure of request in PHP. So my question is.. How looks right request structure in PHP for XML code from above?
public static Guid Login()
{
Response<GetSessionKeyResult> getSessionKeyResult = FamilyInsuranceServiceProxy.FamilyInsuranceServiceWithoutClose.GetSessionKey(new FamilyRequest<GetSessionKeyArgs>()
{ RequestData = new GetSessionKeyArgs() { AgentId = Username, Password = Password } });
CurrentSessionKey = getSessionKeyResult.ResponseData.SessionKey;
return getSessionKeyResult.ResponseData.SessionKey;
}