简体   繁体   中英

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.

Solved

A simple library called PhpWsdl did the trick.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM