从 PHP 代码调用使用 Axis 创建的 Java Web 服务

发布于 2024-08-22 00:41:01 字数 2803 浏览 8 评论 0原文

我正在尝试从 PHP 代码调用使用 Axis 创建的 Java Web 服务。该 Web 服务托管在我的 LAN 上。我能够使用 SoapUI 成功调用 Web 服务。我安装了 PHP Soap 扩展。 但是,我不确定我的 PHP 代码是否正确。下面是我的 PHP 代码。

<?php
 $client = new SoapClient('http://machinename/axis/services/Compiere?wsdl');
 $params = array('in0'=> '124','in1'=>'1');
 $result = $client->__SoapCall('createOrder',array($params));
 print $result->createOrderReturn;
?>

WSDL 如下:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://compservice.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://compservice.com" xmlns:intf="http://compservice.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->

   <wsdl:message name="createOrderRequest">

      <wsdl:part name="in0" type="xsd:int"/>

      <wsdl:part name="in1" type="xsd:int"/>

   </wsdl:message>

   <wsdl:message name="createOrderResponse">

      <wsdl:part name="createOrderReturn" type="xsd:string"/>

   </wsdl:message>

   <wsdl:portType name="OrderServiceInt">

      <wsdl:operation name="createOrder" parameterOrder="in0 in1">

         <wsdl:input message="impl:createOrderRequest" name="createOrderRequest"/>

         <wsdl:output message="impl:createOrderResponse" name="createOrderResponse"/>

      </wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="CompiereSoapBinding" type="impl:OrderServiceInt">

      <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>

      <wsdl:operation name="createOrder">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="createOrderRequest">

            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://compservice.com" use="encoded"/>

         </wsdl:input>

         <wsdl:output name="createOrderResponse">

            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://compservice.com" use="encoded"/>

         </wsdl:output>

      </wsdl:operation>

   </wsdl:binding>

   <wsdl:service name="OrderServiceIntService">

      <wsdl:port binding="impl:CompiereSoapBinding" name="Compiere">

         <wsdlsoap:address location="http://nuca232/axis/services/Compiere"/>

      </wsdl:port>

   </wsdl:service>

</wsdl:definitions>

我的 PHP 代码正确吗?

请帮忙。 谢谢。

Im trying to call a Java web service created using Axis from PHP code.The webservice is hosted on my LAN. I am able to call the web service successfully using SoapUI. I have the PHP Soap Extension installed.
However,im not sure whether my PHP code is correct. Below is my PHP code.

<?php
 $client = new SoapClient('http://machinename/axis/services/Compiere?wsdl');
 $params = array('in0'=> '124','in1'=>'1');
 $result = $client->__SoapCall('createOrder',array($params));
 print $result->createOrderReturn;
?>

The WSDL is as follows :

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://compservice.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://compservice.com" xmlns:intf="http://compservice.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->

   <wsdl:message name="createOrderRequest">

      <wsdl:part name="in0" type="xsd:int"/>

      <wsdl:part name="in1" type="xsd:int"/>

   </wsdl:message>

   <wsdl:message name="createOrderResponse">

      <wsdl:part name="createOrderReturn" type="xsd:string"/>

   </wsdl:message>

   <wsdl:portType name="OrderServiceInt">

      <wsdl:operation name="createOrder" parameterOrder="in0 in1">

         <wsdl:input message="impl:createOrderRequest" name="createOrderRequest"/>

         <wsdl:output message="impl:createOrderResponse" name="createOrderResponse"/>

      </wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="CompiereSoapBinding" type="impl:OrderServiceInt">

      <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>

      <wsdl:operation name="createOrder">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="createOrderRequest">

            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://compservice.com" use="encoded"/>

         </wsdl:input>

         <wsdl:output name="createOrderResponse">

            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://compservice.com" use="encoded"/>

         </wsdl:output>

      </wsdl:operation>

   </wsdl:binding>

   <wsdl:service name="OrderServiceIntService">

      <wsdl:port binding="impl:CompiereSoapBinding" name="Compiere">

         <wsdlsoap:address location="http://nuca232/axis/services/Compiere"/>

      </wsdl:port>

   </wsdl:service>

</wsdl:definitions>

Is my PHP code correct ?

Please help.
Thank You.

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

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

发布评论

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

评论(1

过期以后 2024-08-29 00:41:01

为什么不试试直接模式呢?

 <?php
 $client = new SoapClient('http://machinename/axis/services/Compiere?wsdl');
 $params = array('in0'=> '124','in1'=>'1');
 $result = $client->createOrder( $parms );
 print_r($result);

而不是使用 $client->__SoapCall('createOrder',array($params));

正如手册中所说:“通常,在 WSDL 模式下,SOAP 函数可以调用为SoapClient 对象的方法”

Why don't you try the direct mode?

 <?php
 $client = new SoapClient('http://machinename/axis/services/Compiere?wsdl');
 $params = array('in0'=> '124','in1'=>'1');
 $result = $client->createOrder( $parms );
 print_r($result);

Instead of using $client->__SoapCall('createOrder',array($params));

As the manual says: "Usually, in WSDL mode, SOAP functions can be called as methods of the SoapClient object"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文