- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 WSDL 文件中,函数可以返回类型或元素。到目前为止,我仅使用自定义类型作为结果。但是,我想知道什么时候Element应该比Type更合适?它们有什么区别?
有什么区别吗
<wsdl:message name="MyFunction">
<wsdl:part name="parameters" element="tns:Person"></wsdl:part>
</wsdl:message>
和
<wsdl:message name="MyFunction">
<wsdl:part name="parameters" type="tns:Person"></wsdl:part>
</wsdl:message>
从客户端角度(使用 Web 服务的应用程序)?
正如斯卡夫曼指出的那样,上述问题引出了另一个问题。有什么区别
<xs:element name="Person" ... >
...
</xs:element>
和
<xs:complexType name="Person">
...
</xs:complexType>
?
最佳答案
事情远不止这些。
标准中存在一些含糊之处,可能会导致互操作性问题。您必须使用类型或元素,具体取决于您使用的是基于文档的服务还是基于 RPC 的服务。
也有歧义。如果你说
<wsdl:message name="message1" type="ns:type1"/>
然后您说过消息的内容必须针对类型“ns:type1”进行验证。但您没有提及包含该内容的元素。它将位于哪个命名空间中?
请参阅WS-I Basic Profile有关于此的一些规则。
<小时/>评论中对“文档/文字”与“文档/文字/包装”进行了一些讨论。这是我的看法。
我刚刚创建了一个网络服务。整个事情是这样的:
using System.Web.Services;
namespace WebService1
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class SimpleMathService : WebService
{
[WebMethod]
public int Add(int a, int b)
{
return a + b;
}
[WebMethod]
public int Multiply(int a, int b)
{
return a*b;
}
}
}
我不会发布整个 WSDL,但以下是“好的部分”:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://tempuri.org/" xmlns:tns="http://tempuri.org/" >
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<s:element name="Add">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="a" type="s:int"/>
<s:element minOccurs="1" maxOccurs="1" name="b" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="AddResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1"
name="AddResult" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="int" type="s:int"/>
</s:schema>
</wsdl:types>
<wsdl:message name="AddSoapIn">
<wsdl:part name="parameters" element="tns:Add"/>
</wsdl:message>
<wsdl:message name="AddSoapOut">
<wsdl:part name="parameters" element="tns:AddResponse"/>
</wsdl:message>
<wsdl:portType name="SimpleMathServiceSoap">
<wsdl:operation name="Add">
<wsdl:input message="tns:AddSoapIn"/>
<wsdl:output message="tns:AddSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SimpleMathServiceSoap" type="tns:SimpleMathServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="Add">
<soap:operation soapAction="http://tempuri.org/Add" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SimpleMathService">
<wsdl:port name="SimpleMathServiceSoap" binding="tns:SimpleMathServiceSoap">
<soap:address location="http://localhost:5305/SimpleMathService.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
请注意“wrapped”一词是如何没有出现的。 IBM 在他们的文档中所说的“document/literal/wrapped”只是“document/literal”,它恰好使用单个消息部分,它恰好有一个从服务名称派生的名称,并且恰好引用到一个元素,并且它恰好包含操作的两个参数。
这里没有什么神奇的,这里没有什么不标准的。
在许多标准组织中,公司最终都会选边站。对于 SOAP,我们有“RPC 端”和“文档端”。 RPC 对于很多人来说更为熟悉——它通过函数调用进行一对一的映射。文档不太熟悉,并且要求您实际上用简单的 XML 来思考。也许 IBM 是在 RPC 方面,我不知道。
<小时/>我现在已经完成了 IBM 文档,WSDL 风格。总结如下:
装订样式有四种(确实有五种,但是document/encoded没有意义)。虽然每种样式都有其自己的位置,但在大多数情况下,最好的样式是文档/文字包装。
<小时/>我还想根据消息中是否存在操作名称,对文档中讨论调度难度级别的地方使用react。这不是问题。如果您阅读该文档,您会注意到它从未讨论 <binding>
中的任何内容。部分。 “无操作名称”问题的解决方案就在那里。
<wsdl:binding name="SimpleMathServiceSoap" type="tns:SimpleMathServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="Add">
<soap:operation soapAction="http://tempuri.org/Add" style="document"/>
soapAction 在请求的 HTTP header 中发送,可用于调度:
POST /SimpleMathService.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/Add"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Add xmlns="http://tempuri.org/">
<a>int</a>
<b>int</b>
</Add>
</soap:Body>
</soap:Envelope>
关于wsdl - WSDL 中的类型和元素有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1172118/
我想做的是让 JTextPane 在 JPanel 中占用尽可能多的空间。对于我使用的 UpdateInfoPanel: public class UpdateInfoPanel extends JP
我在 JPanel 中有一个 JTextArea,我想将其与 JScrollPane 一起使用。我正在使用 GridBagLayout。当我运行它时,框架似乎为 JScrollPane 腾出了空间,但
我想在 xcode 中实现以下功能。 我有一个 View Controller 。在这个 UIViewController 中,我有一个 UITabBar。它们下面是一个 UIView。将 UITab
有谁知道Firebird 2.5有没有类似于SQL中“STUFF”函数的功能? 我有一个包含父用户记录的表,另一个表包含与父相关的子用户记录。我希望能够提取用户拥有的“ROLES”的逗号分隔字符串,而
我想使用 JSON 作为 mirth channel 的输入和输出,例如详细信息保存在数据库中或创建 HL7 消息。 简而言之,输入为 JSON 解析它并输出为任何格式。 最佳答案 var objec
通常我会使用 R 并执行 merge.by,但这个文件似乎太大了,部门中的任何一台计算机都无法处理它! (任何从事遗传学工作的人的附加信息)本质上,插补似乎删除了 snp ID 的 rs 数字,我只剩
我有一个以前可能被问过的问题,但我很难找到正确的描述。我希望有人能帮助我。 在下面的代码中,我设置了varprice,我想添加javascript变量accu_id以通过rails在我的数据库中查找记
我有一个简单的 SVG 文件,在 Firefox 中可以正常查看 - 它的一些包装文本使用 foreignObject 包含一些 HTML - 文本包装在 div 中:
所以我正在为学校编写一个 Ruby 程序,如果某个值是 1 或 3,则将 bool 值更改为 true,如果是 0 或 2,则更改为 false。由于我有 Java 背景,所以我认为这段代码应该有效:
我做了什么: 我在这些账户之间创建了 VPC 对等连接 互联网网关也连接到每个 VPC 还配置了路由表(以允许来自双方的流量) 情况1: 当这两个 VPC 在同一个账户中时,我成功测试了从另一个 La
我有一个名为 contacts 的表: user_id contact_id 10294 10295 10294 10293 10293 10294 102
我正在使用 Magento 中的新模板。为避免重复代码,我想为每个产品预览使用相同的子模板。 特别是我做了这样一个展示: $products = Mage::getModel('catalog/pro
“for”是否总是检查协议(protocol)中定义的每个函数中第一个参数的类型? 编辑(改写): 当协议(protocol)方法只有一个参数时,根据该单个参数的类型(直接或任意)找到实现。当协议(p
我想从我的 PHP 代码中调用 JavaScript 函数。我通过使用以下方法实现了这一点: echo ' drawChart($id); '; 这工作正常,但我想从我的 PHP 代码中获取数据,我使
这个问题已经有答案了: Event binding on dynamically created elements? (23 个回答) 已关闭 5 年前。 我有一个动态表单,我想在其中附加一些其他 h
我正在尝试找到一种解决方案,以在 componentDidMount 中的映射项上使用 setState。 我正在使用 GraphQL连同 Gatsby返回许多 data 项目,但要求在特定的 pat
我在 ScrollView 中有一个 View 。只要用户按住该 View ,我想每 80 毫秒调用一次方法。这是我已经实现的: final Runnable vibrate = new Runnab
我用 jni 开发了一个 android 应用程序。我在 GetStringUTFChars 的 dvmDecodeIndirectRef 中得到了一个 dvmabort。我只中止了一次。 为什么会这
当我到达我的 Activity 时,我调用 FragmentPagerAdapter 来处理我的不同选项卡。在我的一个选项卡中,我想显示一个 RecyclerView,但他从未出现过,有了断点,我看到
当我按下 Activity 中的按钮时,会弹出一个 DialogFragment。在对话框 fragment 中,有一个看起来像普通 ListView 的 RecyclerView。 我想要的行为是当
我是一名优秀的程序员,十分优秀!