创建XML模式PHP Soap客户端

时间:2015-06-26 11:57:34

标签: java php xml web-services soap

我正试图从政府提供的网络服务中获取paninfo。 请求样本xml进行服务如下。

<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>

我使用PHP soap客户端如下:

$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);

它生成了以下XML模式

<?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>

作为回应,我得到500内部服务器错误,空响应。

stackoverflow上有相同的问题,但在rails上的ruby中。 any1可以帮助我在PHP中解决它。

  

Savon create matched XML pattern

1 个答案:

答案 0 :(得分:0)

您发送的请求与预期格式不符:

  • 您缺少架构导入类型:xmlns:typ =&#34; http://panws.dit.tcs.com/types/"

  • 您的前缀是&#39; getPanInfo&#39;应该是#pan;而不是ns1

  • 用户名和密码的前缀不是&#39;字符串&#39;但是&#39; typ&#39;

  • 同样适用于panNo