PHP - The formatter threw an exception while trying to deserialize the
Bom dia!!
Estou tentando via PHP, fazer uma requisição a um WebService SOAP, porém estou tendo os seguintes erros(todos no mesmo retorno, apenas separei para facilitar a leitura)
SoapFault Object
(
[message:protected] => The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'CancelaSMP'. End element 'Body' from namespace 'http://schemas.xmlsoap.org/soap/envelope/' expected. Found element 'param1' from namespace ''. Line 2, position 151.
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => C:\wamp\www\ws\webservice\teste.php
[line:protected] => 59
[trace:Exception:private] => Array
[previous:Exception:private] =>
[faultstring] => The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'CancelaSMP'. End element 'Body' from namespace 'http://schemas.xmlsoap.org/soap/envelope/' expected. Found element 'param1' from namespace ''. Line 2, position 151.
[faultcode] => a:DeserializationFailed
[detail] => stdClass Object(
[ExceptionDetail] => stdClass Object
(
[HelpLink] =>
[InnerException] => stdClass Object
(
[HelpLink] =>
[InnerException] =>
[Message] => End element 'Body' from namespace 'http://schemas.xmlsoap.org/soap/envelope/' expected. Found element 'param1' from namespace ''. Line 2, position 151.
[StackTrace] => at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)at System.Xml.XmlBaseReader.ReadEndElement()
at System.ServiceModel.Channels.Message.ReadFromBodyContentsToEnd(XmlDictionaryReader reader, EnvelopeVersion envelopeVersion)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters)
[Type] => System.Xml.XmlException
)
[Message] => The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'CancelaSMP'. End element 'Body' from namespace 'http://schemas.xmlsoap.org/soap/envelope/' expected. Found element 'param1' from namespace ''. Line 2, position 151.
[StackTrace] => at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters)at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
[Type] => System.ServiceModel.Dispatcher.NetDispatcherFaultException
)
)Segue o meu codigo PHP:
<?php
$wsdl = "http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?wsdl";
$trace = true;
$exceptions = false;
$token = 999999999;
$xml_array['token'] = $token;
$xml_array['AnoSMP'] = 2016;
$xml_array['NumeroSMP'] = 0;
$xml = '
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:apis="http://schemas.datacontract.org/2004/07/ApisulLog.Integracao.Modelo.Chamada">
<soapenv:Body>
<tem:CancelaSMP>
<!--Optional:-->
<tem:token>386228449</tem:token>
<!--Optional:-->
<tem:cancelaSMPModeloIntegracao>
<!--Optional:-->
<apis:AnoSMP>2016</apis:AnoSMP>
<!--Optional:-->
<apis:NumeroSMP>0</apis:NumeroSMP>
</tem:cancelaSMPModeloIntegracao>
</tem:CancelaSMP>
</soapenv:Body>
</soapenv:Envelope>
';
print_r($xml_array);
try
{
$client = new SoapClient($wsdl, array('trace' => $trace, 'exceptions' => $exceptions));
$response = $client->CancelaSMP($token, $xml);
}
catch (Exception $e)
{
echo "Error!";
echo $e -> getMessage ();
echo 'Last response: '. $client->__getLastResponse();
}
echo "<pre>";
print_r($response);
echo "</pre>";
Lembrando que o conteudo de $xml foi pego diretamente do SoapUI, onde esta requisição foi feita com sucesso.Discussão (0)
Carregando comentários...