[英]How to call SOAP API through SOAP client in PHP
我正在通过SoapUI之类的一些工具成功获得SOAP API的响应。 我正在使用deltek API。
以下是我在SoapUI中使用的代码格式
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:del="http://tempuri.org/Deltek.Vision.WebServiceAPI.Server/DeltekVisionOpenAPIWebService">
<soap:Header/>
<soap:Body>
<del:GetSchema>
<!--Optional:-->
<del:ConnInfoXML><![CDATA[<VisionConnInfo>
<databaseDescription>Example_Test (TEST_001)</databaseDescription>
<userName>test</userName>
<userPassword>test123</userPassword>
<integratedSecurity>Y</integratedSecurity>
</VisionConnInfo>]]> </del:ConnInfoXML>
<!--Optional:-->
<del:InfoCenter><![CDATA[User]]></del:InfoCenter>
</del:GetSchema>
</soap:Body>
</soap:Envelope>
但是,当我通过php中的SOAP客户端调用API时。 我收到此错误:
stdClass Object
(
[GetSchemaResult] => ErrLoginValInvalid login. Please change the username or password and try again.Value cannot be null.
Parameter name: sGetSchema.validateVisionLogin.VisionWSUtil.ValidateVisionLogin
)
以下是我的PHPcode:
$apiURL = 'http://example.com/Vision/VisionWS.asmx?wsdl';
$client = new SoapClient($apiURL, array('trace' => 1, 'exceptions' => 1));
$conninfo = array(
'ConnInfoXML' => array(
'VisionConnInfo' => array(
"databaseDescription" => 'Example_Test (TEST_001)',
"userName" => "test",
"userPassword" => 'test123',
"integratedSecurity" => "Y"
)
)
);
$userinfo = array('InfoCenter' => 'User');
try {
$result = $client->GetSchema($conninfo, $userinfo);
} catch (SoapFault $fault) {
print_r($fault);
}
echo '<pre>';
print_r($result);
请提出建议? 我在哪里犯错?
如果仔细查看请求,您会发现元素del:ConnInfoXML
包含一个字符串。
为了使其工作,您还必须将ConnInfoXML
设置为字符串:
'ConnInfoXML' => '<VisionConnInfo>...</VisionConnInfo>';
以编程方式创建字符串时,请确保转义值,因此生成的XML有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.