php 为 SOAP 服务器创建 WSDL 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21475828/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 04:10:47  来源:igfitidea点击:

Creating WSDL file for SOAP server

phpweb-servicessoapwsdl

提问by Jan Richter

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.

我是整个 Web 服务的新手,所以我将尽我所能解释我的问题。

I created Soap server in PHP:

我用 PHP 创建了 Soap 服务器:

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:

然后我有一个用于服务器的 Soap 类:

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:

<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.

现在,我需要做的是为服务的“描述”创建简单的 WSDL 文件。我必须说我对整个 Web 服务领域知之甚少,因此我将不胜感激。

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

我熟悉 W3C 文档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.

更新:我试图搜索一些 WSDL 生成器,但似乎都没有工作。

采纳答案by Jan Richter

Solved

解决了

A simple library called PhpWsdl did the trick.

一个名为 PhpWsdl 的简单库实现了这一目标。

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

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