简体   繁体   English

从PHP中的WSDL生成SoapServer

[英]Generate SoapServer from WSDL in PHP

I have a WSDL generated by a webservice in java, and I need to replicate this same web service in a php application. 我有一个由java中的webservice生成的WSDL,我需要在php应用程序中复制这个相同的Web服务。

I looked, and most scripts I found just generate the client. 我看了,我找到的大多数脚本只生成了客户端。 And I need server side that will be consumed. 我需要服务器端将被消耗。

If you have the WSDL then you can simply pass it to the SoapServer class defined in PHP5. 如果你有WSDL,那么你可以简单地将它传递给PHP5中定义的SoapServer类。

$server = new SoapServer("some.wsdl");
$server->setClass('MySoapServer');
$server->handle();

Of course, you'll need to write the MySoapServer class to handle the methods as defined in your WDSL to make this example work. 当然,您需要编写MySoapServer类来处理WDSL中定义的方法,以使此示例有效。

For example, if the WDSL defined an add($a, $b) function, the class would be like so: 例如,如果WDSL定义了一个add($a, $b)函数,那么该类就像这样:

class MySoapServer
{
    public function add($a, $b)
    {
        return $a + $b;
    }
}

Source: http://au1.php.net/manual/en/soapserver.soapserver.php & http://au1.php.net/manual/en/soapserver.setclass.php 资料来源: http//au1.php.net/manual/en/soapserver.soapserver.php&http//au1.php.net/manual/en/soapserver.setclass.php

I was looking for the same functionality, but it's look like it does not exist like this for a server side. 我正在寻找相同的功能,但它看起来像服务器端不存在这样。

After, you can just use a script as wsdl2php to generate the client side classes, and just use the classes for info and respond part it creates... Then you'll use a SoapServer declaration as noetix propose. 之后,你可以使用一个脚本作为wsdl2php来生成客户端类,只需使用类来获取信息并响应它创建的部分...然后你将使用SoeServer声明,因为noetix建议。

There is a good presentation of wsdl2php on this site : http://www.dimuthu.org/blog/2008/09/21/wsdl2php-2-minutes-introduction/ 在这个网站上有一个很好的wsdl2php演示文稿: http//www.dimuthu.org/blog/2008/09/21/wsdl2php-2-minutes-introduction/

If someone know a script to generate the server side, I'm still interested :) 如果有人知道生成服务器端的脚本,我仍然感兴趣:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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