简体   繁体   English

PHP-SOAP SoapFault异常:[客户端]好像我们没有XML文档

[英]PHP-SOAP SoapFault exception: [Client] looks like we got no XML document

i'm currently testing and playing with webservices on my localhost. 我目前正在本地主机上测试和使用Web服务。 I got the "SoapFault exception: [Client] looks like we got no XML document" in the client call of my program and i can't seem to find the reason why. 我的程序的客户端调用中出现了“ SoapFault异常:[客户端]看起来我们没有XML文档”,我似乎找不到原因。

I've already changed the encoding to UTF8 without BOM (as it was suggested on other questions) and still nothing. 我已经将编码更改为不带BOM的UTF8(如在其他问题上所建议的),但仍然没有。 I think it might be because of the complextype i have in my wsdl specification. 我认为这可能是因为我的wsdl规范中包含的复杂类型。

Here's the part of the wsdl that i think that matters: 这是wsdl中我认为很重要的部分:

<types>
<xsd:schema targetNamesace="urn:consulta">
    <xsd:simpleType name="codigo">
        <xsd:restriction base="xsd:string">
            <xsd:minLength value="1"/>
            <xsd:maxLength value="255"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="designacao">
        <xsd:restriction base="xsd:string">
            <xsd:minLength value="1"/>
            <xsd:maxLength value="255"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="unidades">
        <xsd:restriction base="xsd:string">
            <xsd:minLength value="1"/>
            <xsd:maxLength value="255"/>
        </xsd:restriction>
    </xsd:simpleType>   
    <xsd:simpleType name="quantidade">
        <xsd:restriction base="xsd:decimal">
            <xsd:minLength value="2"/>
            <xsd:maxLength value="18"/>
        </xsd:restriction>
    </xsd:simpleType>   
    <xsd:simpleType name="referencia">
        <xsd:restriction base="xsd:string">
            <xsd:minLength value="1"/>
            <xsd:maxLength value="255"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:complexType name="MapaQuantidades">
        <xsd:sequence>
            <xsd:element name="codigo" type="tns:codigo"/>
            <xsd:element name="designacao" type="tns:designacao"/>
            <xsd:element name="unidades" type="tns:unidades"/>
            <xsd:element name="quantidade" type="tns:quantidade"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>
</types>

And the code i'm using on the client: 我在客户端上使用的代码:

    $wsdl= "....";

$soap_options = array(
    'trace'       => 1,     // traces let us look at the actual SOAP messages later
    'exceptions'  => 1 );

$cliente = new SoapClient($wsdl, $soap_options);

$mapaQtds = new StdClass();
$mapaQtds->MapaQuantidades = new StdClass();
$mapaQtds->MapaQuantidades->codigo = 'Codigo WS';
$mapaQtds->MapaQuantidades->designacao = 'Designacao WS';
$mapaQtds->MapaQuantidades->unidades = 'Unidades WS';
$mapaQtds->MapaQuantidades->quantidade = 20;

$soapstruct = new SoapVar($mapaQtds, SOAP_ENC_OBJECT);

$referencia = "Referencia WS";
$designacao = "Designacao Principal";

try{

    $valor = $cliente->create_consulta( $referencia, $designacao, $soapstruct);
    //echo "Resultado = " . $valor;
    echo "REQUEST:\n" . $client->__getLastRequestHeaders() . "\n";

}catch(SoapFault $e){
    var_dump($e);
}

Currently, the function on the server is only returning true... but it seems that the program doesn't even reach the server. 当前,服务器上的函数仅返回true ...,但似乎该程序甚至未到达服务器。 It "dies" in $client->create_consulta. 它在$ client-> create_consulta中“死亡”。 Any idea on why this is happening? 知道为什么会这样吗?

The full error is: 完整的错误是:

Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document     in C:\xampp\htdocs\Integration\Agregation\WSConsultaClient.php:30 Stack trace: #0 C:\xampp\htdocs\Integration\Agregation\WSConsultaClient.php(30): SoapClient->__call('create_consulta', Array) #1 C:\xampp\htdocs\Integration\Agregation\WSConsultaClient.php(30): SoapClient->create_consulta('Referencia WS', 'Designacao Prin...', Object(SoapVar)) #2 {main} thrown in C:\xampp\htdocs\Integration\Agregation\WSConsultaClient.php on line 30

Thx in advance, CR 提前Thx,CR

检查您的服务器代码,我遇到了同样的问题,并且解决了该问题,并删除了页面中的所有回显,?>和html代码,您的server.php必须为空白页面

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM