应该如何WSDL的结构? [英] How should WSDL be structured?
问题描述
由于我是新来的WSDL,WCF和SOAP,我没有真正的线索,我应该如何组织的WSDL。
As I am new to WSDL, WCF and SOAP, I have no real clue how I should structure the WSDL.
我的问题,现在是,当使用自己的用户名密码//用户登录,服务器应该由用户拥有的数据作出反应。让我们说,希望被发回的数据是:
My problem right now is that when a user logs in using their username//password, the server should respond with data owned by the user. Lets say the data that wants to be sent back are:
- MatterID
- MatterTitle
- MatterText
- MatterDate
问题是,每个用户都可以拥有超过1问题,我的问题是,我不知道如何分析比第一的物的多个服务器发送的响应。我的WSDL的结构是这样的:
The problem is that each user can own more than 1 matter and my problem is that I have no idea how to parse more than the first Matter that the server send as response. My WSDL is structured something like this:
在
- 用户名
- 密码
OUT:
- INT MatterID
- 海峡MatterTitle
- 海峡MatterText
- INT MatterDate
我是不是做错了?我应该代替包含所有数据的列表回应?还是有通过响应的方式来循环?
Am I doing it wrong? Should I respond with a list instead containing all the data? Or is there a way to loop through a response?
推荐答案
如果您有数组数据返回,你更好地定义在WSDL列表(类型部分),像这样:
If you have an array of data to return, you better define a list in the WSDL (the types section) like so:
<wsdl:types>
<s:schema xmlns:s="http://www.w3.org/2001/XMLSchema" targetNamespace="http://localhost/SampleService" elementFormDefault="unqualified" attributeFormDefault="unqualified">
<s:complexType name="MatterItemType"> <!-- List Item -->
<s:sequence>
<s:element name="MatterID" type="s:integer" minOccurs="1" maxOccurs="1"/>
<s:element name="MatterTitle" type="s:string" minOccurs="1" maxOccurs="1"/>
<s:element name="MatterText" type="s:string" minOccurs="1" maxOccurs="1"/>
<s:element name="MatterDate" type="s:integer" minOccurs="1" maxOccurs="1"/>
</s:sequence>
</s:complexType>
<s:complexType name="MatterListType"> <!-- List -->
<s:sequence>
<s:element name="MatterItem" type="tns:MatterItemType" minOccurs="0" maxOccurs="unbounded"/>
</s:sequence>
</s:complexType>
<!-- Request and Response -->
<s:element name="SampleRequest">
<s:complexType>
<s:sequence>
<s:element name="username" type="s:string" minOccurs="1" maxOccurs="1"/>
<s:element name="password" type="s:string" minOccurs="1" maxOccurs="1"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="SampleResponse">
<s:complexType>
<s:sequence>
<s:element name="MatterList" type="tns:MatterListType" minOccurs="1" maxOccurs="1"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
的响应总是包含一个 MatterList 元素,它的 MatterListType 。在 MatterListType 包含从0到N MatterItem 中定义项的 MatterItemType
The Response always contains a MatterList element which is of MatterListType. The MatterListType contains from 0 to N MatterItem items defined in the MatterItemType.
的答复将构建这样的事情(不包括SOAP信封,命名空间等,只为结构图):
The response will be structured something like this (not including SOAP envelope, namespaces, etc, just for illustration of the structure):
<SampleResponse>
<MatterList>
<MatterItem>
<MatterID>1</MatterID>
<MatterTitle>Title1</MatterTitle>
<MatterText>Text1</MatterText>
<MatterDate>1</MatterDate>
</MatterItem>
<MatterItem>
<MatterID>2</MatterID>
<MatterTitle>Title2</MatterTitle>
<MatterText>Text2</MatterText>
<MatterDate>2</MatterDate>
</MatterItem>
</MatterList>
</SampleResponse>
让我知道如果你需要在评论中更多的帮助。
Let me know if you need more help in the comments.
这篇关于应该如何WSDL的结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!