Вызов веб-службы Java, созданной с использованием Axis из кода PHP - PullRequest
3 голосов
/ 19 февраля 2010

Я пытаюсь вызвать веб-сервис Java, созданный с помощью Axis из кода PHP. Веб-сервис размещен в моей локальной сети. Я могу успешно вызвать веб-сервис с помощью SoapUI. У меня установлено расширение 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?

Пожалуйста, помогите. Спасибо.

1 Ответ

2 голосов
/ 19 февраля 2010

Почему бы вам не попробовать прямой режим?

 <?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', массив ($ params));

Как сказано в руководстве: «Обычно в режиме WSDL функции SOAP можно вызывать как методы объекта SoapClient»

...