使用SoapClient到.NET Web服务的PHP Soap请求

时间:2012-05-29 14:26:35

标签: php soap service web wsdl

这是我第一次问这里:)

所以,事情就是这样:

我是Web Services WSDL和Soap的新手,但对PHP非常有经验。 我正在尝试向WebService执行Soap请求,这里是URL:

http://webservice.monytor.com.br/WSGeope/ImpExpGEOPE.asmx?WSDL

当我尝试做一个不需要参数的请求时,比如“AVL”,我得到的结果很好:

<?php
$options = array('soap_version' => SOAP_1_2, 'trace' => true, 'exceptions' => true, 'cache_wsdl' => WSDL_CACHE_NONE);
$monytor = new SoapClient("http://webservice.monytor.com.br/WSGeope/ImpExpGEOPE.asmx?WSDL", $options);
$result = $monytor->AVL();
?>

生成:

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://webservices.monytor.com.br/WSGeope/">
<env:Body>
<ns1:AVL/>
</env:Body>
</env:Envelope>

返回我:

<?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:Body>
<AVLResponse xmlns="http://webservices.monytor.com.br/WSGeope/">
<AVLResult>
<anyType xsi:type="xsd:string">AUTOTRAC</anyType>
<anyType xsi:type="xsd:string">CHECKROTA</anyType>
<anyType xsi:type="xsd:string">CONTROLLOC</anyType>

... and so on.

这是完全预期的结果。

但是当我尝试使用一些参数时:

<?php
$options = array('soap_version' => SOAP_1_2, 'trace' => true, 'exceptions' => true, 'cache_wsdl' => WSDL_CACHE_NONE);
$monytor = new SoapClient("http://webservice.monytor.com.br/WSGeope/ImpExpGEOPE.asmx?WSDL", $options);
$result = $monytor->VerifyAccess(array('Empresa' => 1, 'Usuario' => 1, 'Senha' => 'test'));
?>

Wich生成:

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://webservices.monytor.com.br/WSGeope/">
<env:Body>
<ns1:VerifyAccess>
<ns1:Empresa>1</ns1:Empresa>
<ns1:Usuario>1</ns1:Usuario>
<ns1:Senha>test</ns1:Senha>
</ns1:VerifyAccess>
</env:Body>
</env:Envelope>

返回我:

<?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:Body>
<VerifyAccessResponse xmlns="http://webservices.monytor.com.br/WSGeope/">
<VerifyAccessResult>false</VerifyAccessResult>
</VerifyAccessResponse>
</soap:Body>
</soap:Envelope>

(“Empresa”的意思是“公司”,“Usuario”的意思是“用户”,“Senha”的意思是“密码”,当然我在这里发布的是虚构的,但我使用真实的来测试)

根据Web Service支持,参数是正确的,但我的请求XML应如下所示:

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<VerifyAccess xmlns="http://webservices.monytor.com.br/WSGeope/">
<Empresa>1</Empresa>
<Usuario>1</Usuario>
<Senha>test</Senha>
</VerifyAccess>
</soap12:Body>

在任何情况下都没有返回错误(我试过“try ... catch”),所以我提出请求是好的。

我的问题是:这真的可能是“错误”回归的原因,还是证据错误?

如果您在浏览器中访问,则会解释其他方法:http://webservice.monytor.com.br/WSGeope/ImpExpGEOPE.asmx

提前致谢。

抱歉我的英语不好,我是巴西人。

0 个答案:

没有答案