Create XML Pattern PHP Soap Client

I am trying to get paninfo from a government provided web service. Request sample xml for service is as follow.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:pan="http://panws.dit.tcs.com/" xmlns:typ="http://panws.dit.tcs.com/types/">
<soapenv:Header/>
<soapenv:Body>
<pan:getPanInfo>
<login>
<typ:userName>xxxxxxxxxx</typ:userName>
<typ:password>xxxxxxxxxx</typ:password>
</login>
<panNo>
<typ:panNo>xxxxxxxxxx</typ:panNo>
</panNo>
</pan:getPanInfo>
</soapenv:Body>
</soapenv:Envelope>

I have used PHP soap client as follows:

$client = new SoapClient("https://incometaxindiaefiling.gov.in/e-FilingWS/ditws/PanWS.wsdl",array('trace' => 1, 'exceptions' => 0,"cache_wsdl" => 0

));

$client->__setLocation("https://incometaxindiaefiling.gov.in/e-FilingWS/ditws/PanWS");

$params = new SoapVar("<login><string:userName>xxxxxxxxx</string:userName><string:password>xxxxxxxxx</string:password></login><panNo><string:panNo>xxxxxxxxxx</string:panNo></panNo>", XSD_ANYXML);
$result = $client->GetPanInfo($params);

It generated the following XML pattern

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://panws.dit.tcs.com/">
<SOAP-ENV:Body>
<ns1:getPanInfo><login><string:userName>xxxxxxx</string:userName><string:password>xxxxxxx</string:password></login><panNo><string:panNo>xxxxxxx</string:panNo></panNo><panNo/></ns1:getPanInfo></SOAP-ENV:Body>
</SOAP-ENV:Envelope>

In response i got 500 internal server error with empty response.

There is same question on stackoverflow but in ruby on rails. Can any1 help me resolve it in PHP.

Savon create matched XML pattern

Answers


The request you send doesn't match the expected format :

  • You are missing the types schema import : xmlns:typ="http://panws.dit.tcs.com/types/"

  • Your prefix on 'getPanInfo' should be 'pan' and not ns1

  • the prefix on username and password is not 'string' but 'typ'

  • Same for panNo


Need Your Help

Loopback in Route table

windows-7 vmware routes routed-commands loopback-address

I and working on a project to create a WAN emulator using FreeBDS in a VMWare guest configured to route traffic between the host operating system and its normal gateway router. I plan to modify the