Welcome Guest, Not a member yet? Register   Sign In
Sending WSDL file via SOAP
#1
Lightbulb 
(This post was last modified: 04-28-2015, 06:04 PM by ardavan.)

Hi,

Im trying to send a WSDL file to another server.
I have no idea how to do this also this is my first time to work with API(SOAP).

I found a many tutorial about this and they are not working in my application.
The last tutorial is from this website (http://phpsblog.agustinvillalba.com/crea...deigniter/).

I follow everything in this tutorial exactly.

But the problem is with

PHP Code:
$this->nusoap_server = new soap_server(); 

The Error is
Code:
Fatal error: Class 'soap_server' not found in D:\xampp\htdocs\interface\application\controllers\interface\NuSoapServer.php on line 7

And in the box with red border line
Code:
A PHP Error was encountered
Severity: Error
Message: Class 'soap_server' not found
Filename: interface/NuSoapServer.php
Line Number: 7
Backtrace:


Why im getting error about new soap_server?

Thanks
Reply
#2

you must load nusoap library
Reply
#3

(04-28-2015, 09:06 PM)algenza Wrote: you must load nusoap library

Ok, its working well now. but i have the example of this library.
that means will give me "Fruits   apple 4".

I have to read a DB or whatever and then send it by WSDL to a Client. im stuck in this!
Im going to write whole my code in controller & ... except the NuSoap library (because its same).

HOW can i get the data(source isnt important right now) ,  convert to WSDL and then response to the Client?

My Controller
PHP Code:
class NuSoapServer extends CI_Controller {
function 
__construct()
    {
        
parent::__construct();
        
$ns base_url();
        
$this->load->library("Nusoap_library");
        
$this->load->library("Master"); 
        
$this->server = new soap_server(); // it is a soap server object
        
$this->server->configureWSDL("SOAP"$ns); // configure wsdl
        
$this->server->wsdl->schemaTargetNamespace $ns// namespace for the server
    
}


    function 
index()
    {
        
$ns base_url();
        
$input_array = array ('count' => 'xsd:integer''type' => "xsd:string"); // method parameters
        
$return_array = array ("fruit" => "xsd:string");
        
        
//soapAction
        
$this->server->register(
            
'Master.fruits'
            
$input_array
            
$return_array
            
"urn:SOAPServerWSDL"
            
"urn:".$ns."/fruits"
            
"rpc"
            
"encoded"
            
"Fruit Types"
        
);
        
        
$this->server->service(file_get_contents("php://input")); // reading raw data 
    
}

    function 
client(){
        
$this->client = new nusoap_client(base_url()."/index.php/interface/nusoapserver?wsdl"true);

        
$this->load->view("client");
    }


My master.php in libraries folder
PHP Code:
class Master {
 public function 
fruits($count$type)
 {
 
  switch($type)
 
  {
 
   case 'red':
 
    return $count." Apple";
 
    break;
 
   case 'yellow':
 
     return $count." banana";
 
     break;
 
   }
 
 

My Client.php in view folder
PHP Code:
<?php

$error 
$this->client->getError();
if (
$error
{
 echo 
"<h2>Constructor error</h2><pre>" $error "</pre>";
}
 
 
 $result $this->client->call("Master.myfile", array("count" => 4"type" => "red"));
 
 if (
$this->client->fault
{
 
  echo "<h2>Fault</h2><pre>";
 
  print_r($result);
 
  echo "</pre>";
 
  }
 
 else {
 
   $error $this->client->getError();
 
  if ($error) {
 
   echo "<h2>Error</h2><pre>" $error "</pre>";
 
      }
 
 else {
 
   echo "<h2>Correct result</h2><pre>";
 
   echo $result;
 
   echo "</pre>";
 
  }

Reply
#4

did your wsdl appear when you visit your server controller url?

i suggest you to try to request data without input paramater first. so set your server to return data without input parameter when client request the service. if it is work then you can go on and test to request the data with input parameter.
Reply
#5

(04-28-2015, 11:03 PM)algenza Wrote: did your wsdl appear when you visit your server controller url?

i suggest you to try to request data without input paramater first. so set your server to return data without input parameter when client request the service. if it is work then you can go on and test to request the data with input parameter.

Yes Im getting this wsdl data
Code:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://localhost/interface/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://localhost/interface/">
<types>
<xsd:schema targetNamespace="http://localhost/interface/">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
</xsd:schema>
</types>
<message name="Master.fruitsRequest">
<part name="count" type="xsd:integer"/>
<part name="type" type="xsd:string"/>
</message>
<message name="Master.fruitsResponse">
<part name="fruit" type="xsd:string"/>
</message>
<portType name="SOAPPortType">
<operation name="Master.fruits">
<documentation>Fruit Types</documentation>
<input message="tns:Master.fruitsRequest"/>
<output message="tns:Master.fruitsResponse"/>
</operation>
</portType>
<binding name="SOAPBinding" type="tns:SOAPPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="Master.fruits">
<soap:operation soapAction="urn:http://localhost/interface//fruits" style="rpc"/>
<input>
<soap:body use="encoded" namespace="urn:SOAPServerWSDL" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:SOAPServerWSDL" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="SOAP">
<port name="SOAPPort" binding="tns:SOAPBinding">
<soap:address location="http://localhost/interface/index.php/interface/nusoapserver"/>
</port>
</service>
</definitions>
Reply
#6

have you initialized your soap_client object? something like
Code:
$this->client=new soap_client(<server wsdl url>);
Reply
#7

(This post was last modified: 04-28-2015, 11:53 PM by ardavan.)

(04-28-2015, 11:46 PM)algenza Wrote: have you initialized your soap_client object? something like


Code:
$this->client=new soap_client(<server wsdl url>);

No, What should i put?  (http://localhost/interface/index.php/int...soapserver) ??
Reply
#8

(04-28-2015, 11:52 PM)ardavan Wrote:
(04-28-2015, 11:46 PM)algenza Wrote: have you initialized your soap_client object? something like



Code:
$this->client=new soap_client(<server wsdl url>);

No, What should i put?  (http://localhost/interface/index.php/int...soapserver) ??
your server wsdl address Smile
Reply
#9

(This post was last modified: 04-29-2015, 12:03 AM by ardavan.)

(04-28-2015, 11:46 PM)algenza Wrote: have you initialized your soap_client object? something like


Code:
$this->client=new soap_client(<server wsdl url>);

Your mean is http://localhost/interface/mywsdl/myfile.wsdl ?
i need to write something in myfile.wsdl right? can i use sample wsdl from internet and paste into my file?

By the way after put (http://localhost/interface/mywsdl/myfile.wsdl) [file is empty or any other sample] ill get
Code:
WSDL ERROR: Getting http://localhost/interface/mywsdl/myfile - HTTP ERROR: Unsupported HTTP response status 404 Not Found (soapclient->response has contents of the response)
Reply
#10

(04-28-2015, 11:30 PM)ardavan Wrote: Yes Im getting this wsdl data

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




Theme © iAndrew 2016 - Forum software by © MyBB