Z
Z
zz4567go2014-09-12 17:08:39
PHP
zz4567go, 2014-09-12 17:08:39

How to configure case-preserving variable in PHP SOAPClient?

When generating xml for a request, PHP SOAPClient converts all variables passed to the function to lowercase.
For example:

$params = array("Id"=>1);
$client = new SOAPClient($Url, array("cache_wsdl" => WSDL_CACHE_NONE, "trace" => 1));
$forecast = $client->Forecast($params);

I will get in xml
<soap-env:body>
  <ns1:forecast>
    <request>
      <ns2:forecast>
        <ns2:id>1</ns2:id>
      </ns2:forecast>
    </request>
  </ns1:forecast>
</soap-env:body>

How to make the names in xml have the same case as the php variables?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Volintsev, 2014-09-12
@copist

On the one hand, everything depends on the WSDL. It is probably written there that the parameters of this web method are in lower case.
On the other hand, PHP's implementation of SOAP is a rare mischief. Well, just break your hands, and gouge out the eyes of the one who implemented it and shoot the head of the one who decided that PHP can communicate on equal terms over web services with applications in Java, .Net and other languages.
As scary as it sounds, I would recommend implementing SOAP Client and SOAP Server in Java, .Net, or C++. At the same time, PHP will communicate with them via TCP or unix socket with data in JSON format, and they will already work with remote servers or clients using the SOAP protocol. This is called a "proxy" or "bridge". In terms of performance, you will even benefit, because
1. These languages ​​can compile a description of a web service in WSDL format, and PHP interprets
it every time , abandon SOAP in favor of XML-REST or JSON-REST

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question