何时使用 SOAPBinding.ParameterStyle.BARE 和 SOAPBinding.ParameterStyle.WRAPPED [英] when to use SOAPBinding.ParameterStyle.BARE and SOAPBinding.ParameterStyle.WRAPPED

查看:38
本文介绍了何时使用 SOAPBinding.ParameterStyle.BARE 和 SOAPBinding.ParameterStyle.WRAPPED的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对何时使用 SOAPBinding.ParameterStyle.BARE 和 SOAPBinding.ParameterStyle.WRAPPED 感到困惑.以及哪种绑定样式更受欢迎.它们之间有什么区别.

I am in confusion as when to use SOAPBinding.ParameterStyle.BARE and SOAPBinding.ParameterStyle.WRAPPED .and which binding style is more preferred.what are the differences between them.

推荐答案

ParameterStyle.Bare 和 ParameterStyle.Wrapped 仅影响请求和响应消息的 wsdl 定义.

ParameterStyle.Bare and ParameterStyle.Wrapped affects your wsdl definitions of request and response messages only.

让我们举个例子,我们有一个带有方法test"的网络服务,它有两个输入string1"和string2",它返回一个字符串作为rstring".

Lets take an example, we have a webservice with a method "test" which has 2 input "string1" and "string2" and it is returning a string as "rstring".

ParameterStyle.BARE您的参数名称将在 wsdl 中显示为部件名称.

ParameterStyle.BARE Your parameter's name will be visible as part name in your wsdl.

请求消息:

<message name="test">
<part name="string1" element="tns:string1"/>
<part name="string2" element="tns:string2"/>
</message>

响应消息:

<message name="testResponse">
  <part name="rstring" element="tns:rstring"/>
 </message>

在您的 xsd 测试和 testResponse 中定义如下,并且您的 wsdl 元素直接引用被测元素和来自 xsd 的测试响应.

In your xsd test and testResponse will be defined like below, and your wsdl element directly referring elements under test and test response from xsd.

<xs:complexType name="test">
   <xs:sequence>
       <xs:element name="string1" type="xs:string" minOccurs="0"/>
       <xs:element name="string2" type="xs:string" minOccurs="0"/>
   </xs:sequence>

<xs:complexType name="testResponse">
   <xs:sequence>
       <xs:element name="rstring" type="xs:string" minOccurs="0"/>
   </xs:sequence>

ParameterStyle.WRAPPED

在这种样式中,您的请求和响应消息将作为参数"包装在单个输入中,并作为结果"输出.并且他们将引用 xsd 中的所有元素的特定元素.

In this style your request and response message will be wrapped in single input as "parameter" and output as "result". and they will refer that particular element in xsd for all elements within.

请求消息:

 <message name="test">
 <part name="parameters" element="tns:test"/>
 </message>

响应消息:

  <message name="testResponse">
     <part name="result" element="tns:testResponse"/>
 </message>

在您的 xsd 测试和 testResponse 中将定义与上述相同,

In your xsd test and testResponse will be defined as same as above,

<xs:complexType name="test">
   <xs:sequence>
       <xs:element name="string1" type="xs:string" minOccurs="0"/>
       <xs:element name="string2" type="xs:string" minOccurs="0"/>
   </xs:sequence>

<xs:complexType name="testResponse">
   <xs:sequence>
       <xs:element name="rstring" type="xs:string" minOccurs="0"/>
   </xs:sequence>

在上面的示例中,您可以发现差异.这是它们在 wsdl 中唯一的区别.注意:上面的例子是针对文档类型soap绑定的解释,在RPC中,不涉及xsd,所以RPC.Bare只适用.

In above example , you can spot the difference. This is the only difference they implicate in wsdl. Note: Above example is explained for Document type soap binding, in RPC, no xsd is involved so RPC.Bare is applicable only.

这篇关于何时使用 SOAPBinding.ParameterStyle.BARE 和 SOAPBinding.ParameterStyle.WRAPPED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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