Web Services--gSOAP 2.7.6 第七章(7.1.2)

来源:互联网 发布:淘宝直通车出价技巧 编辑:程序博客网 时间:2024/06/11 13:15

下载地址:http://sourceforge.net/projects/gsoap2

官方网站:http://genivia.com/Products/gsoap/index.html

本文翻译只是出于学习的目的,中文部分仅代表个人观点,有错误还望指正,英文部分来自gsoap-win32-2.7\doc\soapdoc2.pdf。其中复制可能有误,可以看懂英文的还请到官网下载。如有版权争议,请联系QQ:643166601,本人会及处理。翻译新手,有错是必然的,求高人指点。欢迎同为新手的你共同学习。

 

7.1.2 Namespace Considerations

7.1.2 命名空间注意事项

The declaration of the ns1__getQuote function prototype (discussed in the previous section) uses the namespace prefix ns1__ of the remote method namespace, which is distinguished by a pair of underscores in the function name to separate the namespace prefix from the remote method name. 

the ns1__getQuote函数原型的声明(在之前的部分讨论过)使用命名空间前缀ns1__的,远程方法命名空间是通过一对下划线辨别的,从远程方法名的函数名称中分离命名空间前缀。

The purpose of a namespace prefix is to associate a remote method name with a service in order to prevent naming conflicts, e.g. to distinguish identical remote method names used by different services.

命名空间前缀是目的是关联一个远程方法名和一个服务为了防止命名冲突,例如区别相同的远程方法名称使用不同的服务。

Note that the XML response of the XMethods Delayed Stock Quote service example uses the namespace prefix n which is bound to the namespace name urn:xmethods-delayed-quotes through the xmlns:n="urn:xmethods-delayed-quotes binding. 

注意XML响应XMethods股票报价服务例子使用的是命名空间前缀是n,帮定到命名空间名称urnxmethods-delayed-quotes通过xmlns:n="urn:xmethods-delayed-quotes 绑定的。

The use of namespace prefixes and namespace names is also required to enable SOAP applications to validate the content of SOAP messages. 

使用命名空间前缀和命名空间名称是使用SOAP应用所需要的,以验证SOAP消息内容。

The namespace name in the service response is verified by the stub routine by using the information supplied in a namespace mapping table that is required to be part of gSOAP client and service application codes. 

在服务响应的命名空间名称是被stub程序使用信息提供检验的,在命名空间映射表中是请求的部分gSOAP客户段和服务端程序代码。

The table is accessed at run time to resolve namespace bindings, both by the generated stubs data structure serializer for encoding the client request and by the generated stubs data structure deserializer to decode and validate the service response. 

这个表在运行时被访问去解决命名空间绑定,通过生成stub的数据结构的序列化的编码的客户端请iuhe生成stub的数据结构的反序列化解码和检验服务响应。

The namespace mapping table should not be part of the header file input to the gSOAP stub and skeleton compiler.

命名空间映射表不应该是头文件输入到gSOAP stub和 skeleton编译器的的一部分。

Service details including namespace bindings may be provided with gSOAP directives in a header file, see Section 18.2.

服务详细包括命名空间绑定可以在gSOAP官方的头文件中提供(找到),请看18.2部分。

 

The namespace mapping table for the Delayed Stock Quote client is:

延迟股票报价客户端的命名空间映射表:

 

struct Namespace namespaces[] =

{ // {ns-prefixns-name}

{SOAP-ENVhttp://schemas.xmlsoap.org/soap/envelope/}, // MUST be first

{SOAP-ENChttp://schemas.xmlsoap.org/soap/encoding/}, // MUST be second

{xsihttp://www.w3.org/2001/XMLSchema-instance}, // MUST be third

{xsdhttp://www.w3.org/2001/XMLSchema}, // 2001 XML Schema

{ns1urn:xmethods-delayed-quotes}, // given by the service description

{NULL, NULL} // end of table

};

 

The first four namespace entries in the table consist of the standard namespaces used by the SOAP 1.1 protocol.

在这个表中的前4行命名空间入口是使用SOAP 1.1协议的标准的命名空间。

In fact, the namespace mapping table is explicitly declared to enable a programmer to specify the SOAP encoding style and to allow the inclusion of namespace-prefix with namespace name bindings to comply to the namespace requirements of a specific SOAP service. 

实际上,命名空间映射表是显示声明使程序员能够指定SOAP编码样式和允许包含命名空间前缀到命名空间名称绑定去遵从一个指定的SOAP服务的命名空间要求。

For example, the namespace prefix ns1, which is bound to urn:xmethods-delayed-quotes by the namespace mapping table shown above, is used by the generated stub routine to encode the getQuote request. 

例如,命名空间前缀是ns1,他是绑定到urn:xmethods-delayed-quotes同过上面显示的命名空间映射表,是被使用的通过生成stub程序去编码getQuote请求。

This is performed automatically by the gSOAP compiler by using the ns1 prefix of the ns1__getQuote method name specified in the getQuote.h header file. 

这个是gSOAP编译器自动执行的使用ns1前缀的ns1__getQuote方法名称是在getQuote.h的头文件中指定的。

In general, if a function name of a remote method, struct name, class name, enum name, or field name of a struct or class has a pair of underscores, the name has a namespace prefix that must be defined in the namespace mapping table.

一般来说,一个远程方法的函数名,stuct名,class名,enum名,或结构体或类的字段名一个对下划线,名称中有一个命名空间前缀,必须在命名空间映射表中定义的。

The namespace mapping table will be output as part of the SOAP Envelope by the stub routine.

命名空间映射表将输出由stub程序SOAP信封的一部分。

For example:

例如:

 

...

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"

xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:xsd="http://www.w3.org/2001/XMLSchema"

xmlns:ns1="urn:xmethods-delayed-quotes"

SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

...

 

The namespace bindings will be used by a SOAP service to validate the SOAP request.

命名空间的绑定将使用SOAP服务去检验SOAP请求。

原创粉丝点击