Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating WSDL file for SOAP server

I am new to the whole web service thing so I will try to explain my problem as much as I can understand it so far.

I created Soap server in PHP:

try {
    $server = new SOAPServer(
        'webservice.wsdl',
        array(
            'uri' => 'http://example.com/soap/server.php'
        )
    );

    $server->setClass('soap');
    $server->handle();
} catch (SOAPFault $f) {
    print $f->faultstring;
}

Then I have a Soap class for the server:

class soap 
{
    public function sendOrders($sXml) 
    {        
        $oXml = new SimpleXMLElement($sXml);
        $sOrder = $oXml->children(); 
        $sResult = '';

        foreach ($sOrder as $OrderRow) {
            $sOrderNr = $OrderRow->ORDERNR;
            $sState = $OrderRow->STATE;
            $sTimestamp = $OrdeRow->TIMESTAMP;

            $oOrder = new Order;
            $oOrder->load($sOrderNr);
            if ($sState == 1) {
                $oOrder->checkStatusChange('Approved', $oOrder);
                $oOrder->{$oOrder->getCoreTableName() . '__status'} = new Field('Approved');
                $sResult .= $sOrderNr . " 1 | ";
            } elseif ($sState == 0) {
                $oOrder->checkStatusChange('Declined', $oOrder);
                $oOrder->{$oOrder->getCoreTableName() . '__status'} = new Field('Declined');
                $sResult .= $sOrderNr . " 0 | ";        
            }

            $oOrder->save();
        }

        return $sResult;   
    }
}

I have a test client that sends simple XML with this format:

<xml>
    <ORDER>
        <ORDERNR>9nmf997d997701e15e30edac107b3664</ORDERNR>
        <STATE>1</STATE>
        <TIMESTAMP>123456789</TIMESTAMP>
    </ORDER>
    <ORDER>
        <ORDERNR>9nmb1c3d4dfb067c04497ea51bd50d06</ORDERNR>
        <STATE>0</STATE>
        <TIMESTAMP>987654321</TIMESTAMP>
    </ORDER>
</xml>

Now, what I need to do is create simple WSDL file for "description" of the service. I must say I have a little knowledge about this whole Web Service area so I would be grateful for any help.

I am familiar with W3C documentation http://www.w3schools.com/webservices/ws_wsdl_documents.asp

Thank you in advance.

Update: I tried to seach for some WSDL generators, none seem to be working.

like image 445
Jan Richter Avatar asked Jan 31 '14 08:01

Jan Richter


People also ask

Can we generate WSDL from SOAP request?

1 - First you need to create the XML schema for the SOAP payloads. For this you can find tools, even some online. After you have the schema, tweak it to your needs by adding, changing or removing elements. 2 - Now you can use the XSD to generate a WSDL.

How do I create a WSDL from a web service?

Generating a WSDL From a Web Service ClassOn the Project Explorer or Navigator tab, right-click the web service class and select Web Services > Generate WSDL.

How to create a WSDL file in SoapUI?

For creating a WSDL file, we have to follow the steps given below: 1 Go to the File -> New SOAP Project. 2 Click on the New SOAP Project; it shows the below screen. 3 Type the following WSDL URL in the Initial WSDL text box, as shown below. ... 4 SoapUI will load and parse the specified WSDL URL contents into the object model, as shown below.

How to create a WSDL file in SAP?

Create a WSDL File. For creating a WSDL file, we have to follow the steps given below: Step 1: Go to the File -> New SOAP Project. Step 2: Click on the New SOAP Project; it shows the below screen. Step 3: Type the following WSDL URL in the Initial WSDL text box, as shown below.

What's the difference between WSDL and soap?

We’ve learned about WSDL files and how they’re related to SOAP. WSDL is a language for describing web or network services. SOAP is a message format for exchanging messages with a server. Try using the example WSDL file above in your own learning projects, or plug it into a testing tool like soapUI.

What is web service description language (WSDL)?

WSDL, or Web Service Description Language, is an XML based definition language. It’s used for describing the functionality of a SOAP based web service. WSDL files are central to testing SOAP-based services. SoapUI uses WSDL files to generate test requests, assertions and mock services. WSDL files define various aspects of SOAP messages:


1 Answers

Solved

A simple library called PhpWsdl did the trick.

https://code.google.com/p/php-wsdl-creator/

like image 68
Jan Richter Avatar answered Oct 10 '22 09:10

Jan Richter