如何使用 wsdl2php 为 PHP Web 服务生成帮助器类和存根代码?

发布于 2024-09-14 00:49:26 字数 852 浏览 4 评论 0原文

我有一个由 WCF 生成的 WSDL,现在应该使用该 WSDL 创建 PHP Web 服务。我的 WSDL 包含到自定义 .NET 类(complexType)的映射,并且我需要一个 PHP WSDL 工具,它可以生成等效的 PHP 类以及存根代码(服务器端生成)。

我读到 wsdl2php 是完成这项工作的正确工具,所以我在以下地址尝试了它: (http://labs.wso2.org/wsf/php/wsdl2phptool.php)

它部分地通过创建存根代码来工作,但它没有创建任何帮助器类(函数参数似乎是 anyType 类型,并且为每个函数只生成一个参数)。我还有可以在 Windows 中使用以下命令运行的脚本版本:

php wsdl2php.php -s http://My.Server.com/MyWCFService/MyWCFService.svc?wsdl> MyWebService.php

但由于某种原因它似乎无法工作,因为它输出一个空文件。我不是 PHP 专家,因为我是 .NET 开发人员,但我需要测试我们的 WSDL 如何与 PHP Web 服务配合使用(只是为了看看是否可以按照与 .NET 中相同的方式从我们的 WSDL 生成 PHP 代码) )。

如果您能给我一个为 PHP Web 服务生成帮助器类和存根代码的简单示例,我将不胜感激。

谢谢! :)

I have a WSDL generated by WCF and now this WSDL should be used to create a PHP web service. My WSDL contains mappings to custom .NET classes (complexType) and I would need a PHP WSDL tool which can generate the equivalent PHP classes as well as the stub code (server-side generation).

I read that the wsdl2php would be the right tool to do the job so I tried it at the address:
(http://labs.wso2.org/wsf/php/wsdl2phptool.php)

It worked partly by creating the stub code but it didn't create any helper classes (function parameters seem to be of type anyType and only one parameter is generated for each function). I have also the script version which I can run with the following kind of command in Windows:

php wsdl2php.php -s http://My.Server.com/MyWCFService/MyWCFService.svc?wsdl > MyWebService.php

but for some reason it doesn't seem to work as it outputs an empty file. I'm not a PHP expert as I am a .NET developer but I would need to test how our WSDL works with PHP web services (just to see that it's possible to generate PHP code from our WSDL in the same way as in .NET).

I would be grateful if you could give me a simple example of generating helper classes and stub code for a PHP web service.

Thanks! :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青丝拂面 2024-09-21 00:49:26

找到解决方案了!为了使用 wsdl2php 生成除了存根代码之外的帮助器类,您将需要一个 WSDL 文件。 wsdl2php 的当前版本(2.1.0)很难理解 WCF 生成的 WSDL。这是由于 WCF WSDL 中使用了导入标记(模式已导入到 wsdl 文档中,而 wsdl2php 不喜欢这样)。

在我使用 WCFExtras 创建单个 WCF WSDL 后,我还设法生成了帮助器类!

"http://wcfextras.codeplex.com/"

"http://weblogs。 asp.net/pglavich/archive/2010/03/16/making-wcf-output-a-single-wsdl-file-for-interop- Purposes.aspx”(首先阅读此内容,因为指定命名空间很重要正确,否则您将遇到 WCFExtras 问题)

Found the solution! In order to generate helper classes in addition to the stub code with wsdl2php you will need a single WSDL file. The current version (2.1.0) of wsdl2php has difficulties to understand the WSDL generated by WCF. This is due to import tags used in the WCF WSDL (schemas have been imported into the wsdl document and wsdl2php doesn't like this)

After I created a single WCF WSDL by using WCFExtras I managed to generate also helper classes!

"http://wcfextras.codeplex.com/"

"http://weblogs.asp.net/pglavich/archive/2010/03/16/making-wcf-output-a-single-wsdl-file-for-interop-purposes.aspx" (read this first as it's important to specify namespaces correctly or you will encounter problems with WCFExtras)

我不咬妳我踢妳 2024-09-21 00:49:26

您还可以使用 T4 模板从服务实现中生成 ServiceProxies 和 DataContract 类。我一直在为我的一个项目开发它们,它们在 GitHub 上发布,包括示例:

https:// github.com/schaermu/wcf-phpclient-t4

以防万一您需要在 .NET 解决方案中使用代理生成逻辑。

You can also use T4 templates for generating ServiceProxies and DataContract classes from your Service implementation. I have been developing them for a project of mine, they are released on GitHub including samples:

https://github.com/schaermu/wcf-phpclient-t4

Just in case you want the proxy-generation logic in your .NET solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文