TechArena Community

TechArena Community (http://forums.techarena.in/)
-   Software Development (http://forums.techarena.in/software-development/)
-   -   Calling a function from a client Web Service (http://forums.techarena.in/software-development/1266108.htm)

HarshaB 02-11-2009 06:27 PM

Calling a function from a client Web Service
 
I recently started in web services. I have a web service that implements 2 functions defined in the wsdl and the corresponding PHP class. When I call $mySoapClient->__getFunctions(), I found out 2 functions in question, with good returns and good settings.

But I call:
  • $mySoapClient-> function1 (...)
  • $mySoapClient-> function2 (...)
  • $mySoapClient-> __soapCall ( 'function1', array (...))
  • $mySoapClient-> __soapCall ( 'function2', array (...))

Function1 is still being evaluated and no way to enforce function2

In this case, when I call $mySoapClient->__getLastRequest(), I see an application where the function name never appears (no "SOAPAction" and therefore no "function1" or "function2" inside) and only the parameters of the function I call appear. Is there some problem with my function call to web service?

void 02-11-2009 06:31 PM

Re: Calling a function from a client Web Service
 
Can you provide us the web service code? Because without that it would be very difficult (almost difficult) for anyone to solve your problem!

HarshaB 02-11-2009 06:38 PM

Re: Calling a function from a client Web Service
 
I apologize for my mistake!

I must had added that initially, by exchanging the order of statements 2 functions in the binding was only the function2 that was running, and when I tried to call function1, it made me crash, then restart Apache .

Here's the code:

Code:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
 xmlns:tns="http://plopInc/Plopservice" 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" targetNamespace="http://plopInc/Plopservice">
 
 <wsdl:types>
  <schema elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema"
  xmlns:tns="http://plopInc/Plopservice" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://plopInc/Plopservice">
 
  <simpleType name="EnumerationStatus">
    <xsd:restriction base="xsd:string">
    <xsd:enumeration value="Success" />
    <xsd:enumeration value="Warning" />
    <xsd:enumeration value="Failure" />
    </xsd:restriction>
  </simpleType>
 
  <complexType name="serviceReturn">
    <sequence>
    <element minOccurs="1" maxOccurs="1" name="status"
      type="tns:EnumerationStatus" />
    <element minOccurs="0" maxOccurs="1" name="code" type="xsd:string" />
    <element minOccurs="0" maxOccurs="1" name="message" type="xsd:string" />
    </sequence>
  </complexType>
 
  <!--
    ******************************************************************************
  -->
 
  <complexType name="Contact">
    <sequence>
    <element minOccurs="0" maxOccurs="1" name="id" type="xsd:long" />
    <element minOccurs="1" maxOccurs="1" name="name" type="xsd:string" />
    <element minOccurs="1" maxOccurs="1" name="prename" type="xsd:string" />
    <element minOccurs="0" maxOccurs="1" name="listTelephones"
      type="tns:ListTelephones" />
    </sequence>
  </complexType>
 
  <complexType name="ListContacts">
    <sequence>
    <element minOccurs="0" maxOccurs="unbounded" name="Contact"
      nillable="true" type="tns:Contact" />
    </sequence>
  </complexType>
 
  <complexType name="Telephone">
    <sequence>
    <element minOccurs="0" maxOccurs="1" name="label" type="xsd:string" />
    <element minOccurs="0" maxOccurs="1" name="numeral" type="xsd:string" />
    </sequence>
  </complexType>
 
  <complexType name="ListTelephones">
    <sequence>
    <element minOccurs="0" maxOccurs="unbounded" name="Telephone"
      nillable="true" type="tns:Telephone" />
    </sequence>
  </complexType>
 
  <!--
    ******************************************************************************
  -->
 
  <element name="SearchContactResponse">
    <complexType>
    <sequence>
      <element minOccurs="1" maxOccurs="1" name="serviceReturn"
      type="tns:serviceReturn" />
      <element minOccurs="0" maxOccurs="1" name="listContacts"
      type="tns:ListContacts" />
    </sequence>
    </complexType>
  </element>
 
  <element name="UpdateContactResponse">
    <complexType>
    <sequence>
      <element minOccurs="1" maxOccurs="1" name="serviceReturn"
      type="tns:serviceReturn" />
      <element minOccurs="0" maxOccurs="1" name="contact" type="tns:Contact" />
    </sequence>
    </complexType>
  </element>
 
  </schema>
 </wsdl:types>
 
 <!--
  ******************************************************************************
 -->
 
 <wsdl:message name="SearchContactIn">
  <part name='idUser' type='xsd:string' />
 </wsdl:message>
 <wsdl:message name="SearchContactOut">
  <wsdl:part name="parameters" element="tns:SearchContactResponse" />
 </wsdl:message>
 
 <wsdl:message name="UpdateContactIn">
  <part name='idUser' type='xsd:string' />
  <part name='contact' type='tns:Contact' />
 </wsdl:message>
 <wsdl:message name="UpdateContactOut">
  <wsdl:part name="parameters" element="tns:UpdateContactResponse" />
 </wsdl:message>
 
 <!--
  ******************************************************************************
 -->
 
 <wsdl:portType name="PlopService">
  <wsdl:operation name="SearchContact">
  <wsdl:input message="tns:SearchContactIn" />
  <wsdl:output message="tns:SearchContactOut" />
  </wsdl:operation>
 
  <wsdl:operation name="UpdateContact">
  <wsdl:input message="tns:UpdateContactIn" />
  <wsdl:output message="tns:UpdateContactOut" />
  </wsdl:operation>
 </wsdl:portType>
 
 <!--
  ******************************************************************************
 -->
 
 <wsdl:binding name="PlopServiceSOAPBinding" type="tns:PlopService">
  <wsdlsoap:binding style="document"
  transport="http://schemas.xmlsoap.org/soap/http" />
 
  <wsdl:operation name="SearchContact">
  <wsdlsoap:operation soapAction="http://plopInc/Plopservice/SearchContact"
    style="document" />
  <wsdl:input>
    <wsdlsoap:body use="literal" namespace="http://plopInc/Plopservice" />
  </wsdl:input>
  <wsdl:output>
    <wsdlsoap:body use="literal" namespace="http://plopInc/Plopservice" />
  </wsdl:output>
  </wsdl:operation>
 
  <wsdl:operation name="UpdateContact">
  <wsdlsoap:operation soapAction="http://plopInc/Plopservice/UpdateContact"
    style="document" />
  <wsdl:input>
    <wsdlsoap:body use="literal" namespace="http://plopInc/Plopservice" />
  </wsdl:input>
  <wsdl:output>
    <wsdlsoap:body use="literal" namespace="http://plopInc/Plopservice" />
  </wsdl:output>
  </wsdl:operation>
 
 </wsdl:binding>
 
 <wsdl:service name="PlopServiceService">
  <wsdl:port name="PlopService" binding="tns:PlopServiceSOAPBinding">
  <wsdlsoap:address location="http://127.0.0.1/PlopService/PlopService.php" />
  </wsdl:port>
 </wsdl:service>
 
</wsdl:definitions>


void 02-11-2009 06:46 PM

Re: Calling a function from a client Web Service
 
Well unfortunately I am like you, very new to the area. I just had to use in some time without problem.

As I can not at all find out where the problem might occur from, I advise you, if you have not already, test your Web service with Webservice Studio tool.

.NET Webservice Studio is a tool to invoke webmethods interactively. You can provide a WSDL endpoint. On clicking button Get the tool fetches the WSDL, generates .NET proxy from the WSDL and displays the list of methods available. You can then choose any method and provide the required input parameters. On clicking Invoke the SOAP request is sent to the server and the response is parsed to display the return value.

In other words, this tool is meant for webservice implementers to test their webservices without having to write the client code. This could also be used to access other webservices whose WSDL endpoint is known.


If it behaves as you wish, in this case is that it comes from the PHP code in which case I invite you to post your real PHP code.


All times are GMT +5.5. The time now is 06:26 PM.