gpt4 book ai didi

php - SOAP 错误 : Encoding: Violation of encoding rules?

转载 作者:可可西里 更新时间:2023-11-01 00:17:00 28 4
gpt4 key购买 nike

我正在尝试使用 Yii 来提供网络服务。自动生成的 wsdl 如下。我可以从命令行成功使用 Web 服务,但是通过 Web 浏览器,我得到了

SOAP-ERROR: Encoding: Violation of encoding rules

我是 SOAP 的新手,所以我不确定如何调试问题。这是我用来使用 Web 服务的 PHP 代码:

<?php
$client=new SoapClient('{url omitted for security}',
array('trace'=>1,'exceptions'=>1));
try {
$result = $client->getPerson(90043412);
var_dump($result);
} catch (SoapFault $fault) {
echo $fault->getMessage() . '<br />';
echo 'REQUEST <br />';
echo '<pre>';
echo $client->__getLastRequestHeaders();
echo $client->__getLastRequest();
echo '</pre>';
echo 'RESPONSE <br />';
echo '<pre>';
echo $client->__getLastResponseHeaders();
echo $client->__getLastResponse();
echo '</pre>';
echo 'TRACE <br />';
echo '<pre>';
var_dump($fault->getTrace());
echo '</pre>';
}
?>

这是 WSDL:

<?xml version="1.0" encoding="UTF-8"?> 
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="urn:PersonControllerwsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" name="PersonController" targetNamespace="urn:PersonControllerwsdl">
<wsdl:types>
<xsd:schema targetNamespace="urn:PersonControllerwsdl">
<xsd:complexType name="Person">
<xsd:all>
<xsd:element name="PIDM" type="xsd:integer"/>
<xsd:element name="FirstName" type="xsd:string"/>
<xsd:element name="MiddleName" type="xsd:string"/>
<xsd:element name="LastName" type="xsd:string"/>
<xsd:element name="PrefFirstName" type="xsd:string"/>
<xsd:element name="CPOBox" type="xsd:string"/>
<xsd:element name="Classification" type="xsd:string"/>
<xsd:element name="Email" type="xsd:string"/>
<xsd:element name="PhotoFile" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="getPersonRequest">
<wsdl:part name="PIDM" type="xsd:int"/>
</wsdl:message>
<wsdl:message name="getPersonResponse">
<wsdl:part name="return" type="tns:Person"/>
</wsdl:message>
<wsdl:portType name="PersonControllerPortType">
<wsdl:operation name="getPerson">
<wsdl:documentation></wsdl:documentation>
<wsdl:input message="tns:getPersonRequest"/>
<wsdl:output message="tns:getPersonResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="PersonControllerBinding" type="tns:PersonControllerPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getPerson">
<soap:operation soapAction="urn:PersonControllerwsdl#getPerson" style="rpc"/>
<wsdl:input>
<soap:body use="encoded" namespace="urn:PersonControllerwsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:input>
<wsdl:output>
<soap:body use="encoded" namespace="urn:PersonControllerwsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="PersonControllerService">
<wsdl:port name="PersonControllerPort" binding="tns:PersonControllerBinding">
<soap:address location="https://localhost/whoswho/person/service?ws=1"/>
</wsdl:port>
</wsdl:service>
</definitions>

最佳答案

SOAP 请求的格式可能不正确。我一直在使用 SoapUI,默认情况下所有参数都设置为“?”最初,如果您发出此请求,PHP 将失败并返回您报告的错误消息。你无法捕获它,因为没有抛出异常,这是因为它是一个 fatal error 。

您可以使用 set_error_handler() 函数为这种情况设置自己的错误处理程序 http://php.net/manual/en/function.set-error-handler.php

关于php - SOAP 错误 : Encoding: Violation of encoding rules?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5638910/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com