简体   繁体   English

PHP的肥皂与类的电话

[英]php soap call with class

I have a webservice written in Java, and I want to use it by php. 我有一个用Java编写的Web服务,我想通过php使用它。 It need a class, say "UserDemand", as one of the parameters. 它需要一个类,例如“ UserDemand”,作为参数之一。 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是这样的:

<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. 已添加callSupport。 I test the webservice with java code, it works ok. 我用Java代码测试了Web服务,它工作正常。

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. 但是,当我将它与php一起使用(并使用CodeIgniter)时,Java端无法设置callSupport,它甚至永远也不会调用函数“ setCallSupport”,但是策略和其他属性仍然可以工作。 The php is ad below: 的PHP是下面的广告:

$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. 我只是添加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. 只需使用SoapVar即可解决。

$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! 这意味着旧代码不起作用,但确实起作用了!

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

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