我目前正在我的localhost上测试和使用webservices。我在我的程序的客户端调用中得到了“SoapFault异常:[Client]看起来我们没有XML文档”,我似乎无法找到原因。
我已经将编码更改为没有BOM的UTF8(正如其他问题所建议的那样),但仍然没有。我想这可能是因为我的wsdl规范中有复杂的类型。
以下是我认为重要的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>
我正在客户端上使用的代码:
$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);
}
目前,服务器上的功能只返回true ...但似乎程序甚至没有到达服务器。它在$ client-&gt; create_consulta中“死”。对于为什么会发生这种情况的任何想法?
完整错误是:
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
提前, CR
答案 0 :(得分:0)
检查你的服务器代码,我有同样的问题,我解决了它删除页面中的每个echo,?&gt;和html代码,你的server.php必须是一个空白页