SOAP中的哪些类型映射到枚举? [英] What type in SOAP maps to enumerations?

查看:86
本文介绍了SOAP中的哪些类型映射到枚举?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

服务器端数据库中的字段定义为ENUM。通过包括该字段的Web服务返回一行数据库。我必须为返回的结果定义一个类型。在PHP中,我使用NuSoap来实现此目的。我使用addComplexType函数。应该如何调用此函数?用什么参数?应该如何定义类型?在更新Web引用之后,我更喜欢使用Visual Studio生成的代码,包括字段的枚举而不是简单的字符串或整数。

我希望我能解释一下我需要什么。



我尝试了什么:



我以前把它映射到字符串,但是从字符串到枚举以及从枚举返回到客户端字符串是一种开销。

A field in database at server-side is defined as ENUM. A row of database is returned via a web service including the field. I have to define a type for the returned result. In PHP, I use NuSoap for this purpose. I use addComplexType function. How this function should be called? With what parameters? How the definition of the type should be? I prefer the produced code with Visual Studio, after I update the web references, include an enumeration for the field instead of a simple string or integer.
I hope I could explain what I need good.

What I have tried:

I used to map it to string, but translation from string to enum and from enum back to string at client-side is an overhead.

推荐答案

这是创建新类型的方法的示例枚举:

Here is an example of the method for creating a new type of enum:


server-> wsdl-> addSimpleType('ServerStatus','xsd:string','SimpleType' ,'struct',
数组(
'Off',
'停止',
'运行'
));
server->wsdl->addSimpleType('ServerStatus', 'xsd:string', 'SimpleType', 'struct', array(‎ 'Off', 'Stopped', 'Running' ));





然后,在服务器结构中,以下行定义服务器的状态:



Then, in Server structure the following line defines the server's status:

'Status' => array('name' => 'Status', 'type'=> 'tns:ServerStatus')



在客户端更新Web引用时,ServerStatus是翻译成枚举。


When web references are updated at client side, ServerStatus is translated to enum.


这篇关于SOAP中的哪些类型映射到枚举?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆