Zend_Soap_Client如何获取结果complexType

发布于 2024-11-26 14:52:08 字数 1921 浏览 0 评论 0原文

我正在尝试调用一个将复杂类型描述为输入和输出参数的 Web 服务

<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
  <s:element name="getTermsForService">
    <s:complexType>
      <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="universalid" type="s:string" />
      </s:sequence>
    </s:complexType>
  </s:element>
  <s:element name="getTermsForServiceResponse">
    <s:complexType>
      <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="getTermsForServiceResult" type="tns:ArrayOfString" />
      </s:sequence>
    </s:complexType>
  </s:element>
  <s:complexType name="ArrayOfString">
    <s:sequence>
      <s:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="s:string" />
    </s:sequence>
  </s:complexType>
</s:schema>
</wsdl:types>

<wsdl:message name="getTermsForServiceSoapIn">
   <wsdl:part name="parameters" element="tns:getTermsForService" >
</wsdl:message>
<wsdl:message name="getTermsForServiceSoapOut">
  <wsdl:part name="parameters" element="tns:getTermsForServiceResponse" />
</wsdl:message>
<wsdl:portType name="Service1Soap">
<wsdl:operation name="getTermsForService">
  <wsdl:input message="tns:getTermsForServiceSoapIn" />
  <wsdl:output message="tns:getTermsForServiceSoapOut" />
</wsdl:operation>
</wsdl:portType>

我认为调用它会像以下一样简单:

$client = new Zend_Soap_Client($this->config->webserviceWsdlFile); 

try { 
     $result = $client->getTermsForService($_GET['universalid']); 
} catch (Exception $e) { 
    // @TODO catch correctly 
       var_dump($e); 
}

但似乎并非如此。那么我该怎么做才能得到答案中包含字符串的正确结果......

I'm trying to call a webservice that has complexTypes described as input and output params

<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
  <s:element name="getTermsForService">
    <s:complexType>
      <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="universalid" type="s:string" />
      </s:sequence>
    </s:complexType>
  </s:element>
  <s:element name="getTermsForServiceResponse">
    <s:complexType>
      <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="getTermsForServiceResult" type="tns:ArrayOfString" />
      </s:sequence>
    </s:complexType>
  </s:element>
  <s:complexType name="ArrayOfString">
    <s:sequence>
      <s:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="s:string" />
    </s:sequence>
  </s:complexType>
</s:schema>
</wsdl:types>

And

<wsdl:message name="getTermsForServiceSoapIn">
   <wsdl:part name="parameters" element="tns:getTermsForService" >
</wsdl:message>
<wsdl:message name="getTermsForServiceSoapOut">
  <wsdl:part name="parameters" element="tns:getTermsForServiceResponse" />
</wsdl:message>
<wsdl:portType name="Service1Soap">
<wsdl:operation name="getTermsForService">
  <wsdl:input message="tns:getTermsForServiceSoapIn" />
  <wsdl:output message="tns:getTermsForServiceSoapOut" />
</wsdl:operation>
</wsdl:portType>

I thought, calling it would be as eaysy as:

$client = new Zend_Soap_Client($this->config->webserviceWsdlFile); 

try { 
     $result = $client->getTermsForService($_GET['universalid']); 
} catch (Exception $e) { 
    // @TODO catch correctly 
       var_dump($e); 
}

But it seems it isn't. So what do I have to do to get a correct result with a string in the answer...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

潇烟暮雨 2024-12-03 14:52:08

实际上很容易

$client = new Zend_Soap_Client($this->config->webserviceWsdlFile); 

try { 
   $result = $client->getTermsForService(array('universalid' => $_GET['universalid']);
   var_dump($result->getTermsForServiceResponse);
} catch (Exception $e) { 
// @TODO catch correctly 
   var_dump($e); 
}

给出正确的结果:

object(stdClass)[123]
  public 'string' => 
    array
      0 => string '0815' (length=10)
      1 => string '0816' (length=10)

actually it was really easy

$client = new Zend_Soap_Client($this->config->webserviceWsdlFile); 

try { 
   $result = $client->getTermsForService(array('universalid' => $_GET['universalid']);
   var_dump($result->getTermsForServiceResponse);
} catch (Exception $e) { 
// @TODO catch correctly 
   var_dump($e); 
}

gave the correct result:

object(stdClass)[123]
  public 'string' => 
    array
      0 => string '0815' (length=10)
      1 => string '0816' (length=10)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文