CodeIgniter Forums

Full Version: Sending WSDL file via SOAP
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(04-29-2015, 12:01 AM)algenza Wrote: [ -> ]
(04-28-2015, 11:30 PM)ardavan Wrote: [ -> ]Yes Im getting this wsdl data

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<definitions xmlns:SOAP-ENV="" xmlns:xsd="" xmlns:xsi="" xmlns:SOAP-ENC="" xmlns:tns="http://localhost/interface/" xmlns:soap="" xmlns:wsdl="" xmlns="" targetNamespace="http://localhost/interface/">
<xsd:schema targetNamespace="http://localhost/interface/">
<xsd:import namespace=""/>
<xsd:import namespace=""/>
<message name="Master.fruitsRequest">
<part name="count" type="xsd:integer"/>
<part name="type" type="xsd:string"/>
<message name="Master.fruitsResponse">
<part name="fruit" type="xsd:string"/>
<portType name="SOAPPortType">
<operation name="Master.fruits">
<documentation>Fruit Types</documentation>
<input message="tns:Master.fruitsRequest"/>
<output message="tns:Master.fruitsResponse"/>
<binding name="SOAPBinding" type="tns:SOAPPortType">
<soap:binding style="rpc" transport=""/>
<operation name="Master.fruits">
<soap:operation soapAction="urn:http://localhost/interface//fruits" style="rpc"/>
<soap:body use="encoded" namespace="urn:SOAPServerWSDL" encodingStyle=""/>
<soap:body use="encoded" namespace="urn:SOAPServerWSDL" encodingStyle=""/>
<service name="SOAP">
<port name="SOAPPort" binding="tns:SOAPBinding">
<soap:address location="http://localhost/interface/index.php/interface/nusoapserver"/>
url that generate this wsdl

This is the link of generating that XML

When i put this inside this my apache port will goes on +324 million ports.!!
you have to separate your soap client and soap server application or at least put them on different controller
Ok ive created a new controller for my client and i called that controllers/Client.php
And ive paste the client funtion from my nusoapserver controller to client controller.

PHP Code:
class Client extends CI_Controller{
$this->client = new nusoap_client(base_url()."/index.php/interface/nusoapserver?wsdl"true);


How about now?
Ok this is my soap server:
PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

Mysoapserver extends CI_Controller {

    public function 

=new nusoap_server 



       $input_array = array ('count' => 'xsd:integer''type' => "xsd:string"); // method parameters
       $return_array = array ("fruit" => "xsd:string");

       ##register function
           "Fruit Types"

       ##function that will do the job
       function fruits($count,$type){
           case 'red':
               return $count." Apple";
           case 'yellow':
               return $count." banana";


and this is my soap client
PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Mysoapclient extends CI_Controller {

##load the library
##initialize soap client
$client=new nusoap_client("http://localhost:85/apiserver/mysoapserver");
##client call server function and get the response
$response=$client->call('fruits',array("count" => 4"type" => "red"));
##if no error then you can view server response
echo $response;

if you call the client url then it will show '4 Apple'.
Cool,Thanks for it. But still i need to know how to get my details instead of '4 Apple'.

I was trying to create a sample WSDL file to request and response. could you help me in this also?

define complex type that match your query result in your wsdl
(05-05-2015, 01:36 AM)algenza Wrote: [ -> ]define complex type that match your query result in your wsdl

Thanks, it works finally.
I just needed to assign the exact tag's names.
good to know it works Smile
(05-17-2015, 07:13 PM)algenza Wrote: [ -> ]good to know it works Smile
Im not too happy because it was only client side. I could only receive the data.
Now i wanna send some data to some client.

im using your code which is you answered to me.
I cant see any '4 Apple' on my browser and the result from Client link is:

Constructor error

SOAP-ENV:Client: Operation 'fruits' is not defined in the WSDL for this service

POST /backfill/index.php/interface/nusoapserver/server?wsdl HTTP/1.0
Host: localhost
User-Agent: NuSOAP/0.9.5 (1.123)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: ""
Content-Length: 535

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="" xmlns:SOAP-ENV="" xmlns:xsd="" xmlns:xsi="" xmlns:SOAP-ENC=""><SOAP-ENV:Body><ns7923:fruits xmlns:ns7923=""><count xsi:type="xsd:int">4</count><type xsi:type="xsd:string">red</type></ns7923:fruits></SOAP-ENV:Body></SOAP-ENV:Envelope>

HTTP/1.0 500 Internal Server Error
Date: Thu, 21 May 2015 06:50:24 GMT
Server: Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.5.19
X-Powered-By: PHP/5.5.19
Set-Cookie: ci_session=dd10680820baf510a3102ce971f83a344746f4f1; expires=Thu, 21-May-2015 08:50:24 GMT; Max-Age=7200; path=/; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Status: 500 Internal Server Error
X-SOAP-Server: NuSOAP/0.9.5 (1.123)
Content-Length: 706
Connection: close
Content-Type: text/xml; charset=ISO-8859-1

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle=""
<SOAP-ENV:Body><SOAP-ENV:Fault><faultcode xsi:type="xsd:string">SOAP-ENV:Client</faultcode><faultactor xsi:type="xsd:string"></faultactor><faultstring xsi:type="xsd:string">Operation &apos;fruits&apos; is not defined in the WSDL for this service</faultstring><detail xsi:type="xsd:string"></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>

2015-05-21 08:50:24.356595 nusoap_client: ctor wsdl= timeout=0 response_timeout=30
endpoint=string(70) "http://localhost/backfill/index.php/interface/nusoapserver/server?wsdl"
2015-05-21 08:50:24.356595 nusoap_client: instantiate SOAP with endpoint at http://localhost/backfill/index.php/interface/nusoapserver/server?wsdl
2015-05-21 08:50:24.356595 nusoap_client: call: operation=fruits, namespace=, soapAction=, rpcParams=, style=rpc, use=encoded, endpointType=soap
params=array(2) {
 string(3) "red"
2015-05-21 08:50:24.356595 nusoap_client: serializing param array for operation fruits
2015-05-21 08:50:24.356595 nusoap_client: in serialize_val: name=count, type=, name_ns=, type_ns=, use=encoded, soapval=
2015-05-21 08:50:24.356595 nusoap_client: serialize_val: serialize int
2015-05-21 08:50:24.356595 nusoap_client: serialize_val returning <count xsi:type="xsd:int">4</count>
2015-05-21 08:50:24.356595 nusoap_client: in serialize_val: name=type, type=, name_ns=, type_ns=, use=encoded, soapval=
value=string(3) "red"
2015-05-21 08:50:24.356595 nusoap_client: serialize_val: serialize string
2015-05-21 08:50:24.356595 nusoap_client: serialize_val returning <type xsi:type="xsd:string">red</type>
2015-05-21 08:50:24.357595 nusoap_client: wrapping RPC request with encoded method element
2015-05-21 08:50:24.357595 nusoap_client: In serializeEnvelope length=138 body (max 1000 characters)=<ns7923:fruits xmlns:ns7923=""><count xsi:type="xsd:int">4</count><type xsi:type="xsd:string">red</type></ns7923:fruits> style=rpc use=encoded encodingStyle=
2015-05-21 08:50:24.357595 nusoap_client: headers:
2015-05-21 08:50:24.357595 nusoap_client: namespaces:

Whats the problem here? i changed the ns and client link for several times. still its same
UPDATE: in the client function code i just put fruits instead of fruit.
Now It works.

I need to get the data from my DB. We assume i got all the rows and put inside rows[].
Now how can i replace with:

PHP Code:
##function that will do the job
       function BigData($count,$type){
           case 'red':
               return $count." Apple";
           case 'yellow':
               return $count." banana";
Pages: 1 2