简体   繁体   中英

php soap call with class

I have a webservice written in Java, and I want to use it by php. It need a class, say "UserDemand", as one of the parameters. It works before( the code is written by others ), but I add an attribute, and it does not work anymore. The wsdl is like this:

<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://statistic.bupt.com">
  <import namespace="http://bupt.com"/>
  <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
  <complexType name="UserDemand">
    <sequence>
      <element name="callSupport" type="xsd:int"/>
      <element name="caps" type="xsd:int"/>
      <element name="strategy" type="xsd:int"/>
      <element name="video" type="xsd:int"/>
    </sequence>
  </complexType>
 ...

The callSupport is added. I test the webservice with java code, it works ok.

But when I use it with php (and use CodeIgniter), the java side can't set callSupport, it even never call the function "setCallSupport", but the strategy and other attribute can still work. The php is ad below:

$this->load->library('UserDemand');
$userDemand = new UserDemand();
$userDemand->callSupport = $call_support;
$userDemand->caps = $audio_count;
$userDemand->video = $media_count;
$userDemand->strategy = $strategy;

$client = new SoapClient($ws_base_url.$wsdl_class.'?wsdl');
$param = array($username, $userDemand);
$out = $client->__soapCall($wsdl_function, $param);

And I just add callSupport. So, why I can't receive it, or actually it is recieved but just can't be set?

I have find a way to solve the problem. Just use SoapVar to solve it.

$x = new SoapVar($userDemand,SOAP_ENC_OBJECT);
$param = array($username, $x);

But I'm still confuesd about that if I have to do so, it must have been done before. It means the old code should not work, but it did work!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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