高手指点,开发一个WebService供各种开发语言调用.

bigtree0906 2011-05-23 10:19:07
最近需要用C#开发一个WebService服务,以供各种不同的开发语言(C#、Delphi、PB、Java)进行调用。具体需求如下:
1、数据库中有一故障原因表,结构为“故障原因编号, 故障原因描述”。数据如下:

故障原因编号 故障原因描述
14 关阀
15 不读卡
16 无显示
17 漏水
26 其他


2、需要用C#开发一个WebService服务,方法名为GetFaulCause。返回的数据为对上述数据以XML进行封装文档,
以便让(C#、Delphi、PB、Java)各种不同的开发语言开发的客户端程序进行调用。

3、高手们能进一步提供(C#、Delphi、PB、Java)调用实例就更好,将感激不尽,多多给分。:)
...全文
113 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhouxingyu896 2011-06-10
  • 打赏
  • 举报
回复
支持4楼的
也学习4楼的
weike021996 2011-05-26
  • 打赏
  • 举报
回复
mark
夕甜 2011-05-24
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 fangxinggood 的回复:]
跨语言的最好考虑用 RESTful 的方式。即直接通过HttpWebRequest方式调用的。

http://blog.csdn.net/fangxinggood/archive/2011/03/14/6247297.aspx
[/Quote]

是啊 Web Service是跨平台的 你在web Service 中还发布后测试 看能否访问
bigtree0906 2011-05-23
  • 打赏
  • 举报
回复
数据显示的结果如下:


<?xml version="1.0" encoding="utf-8" ?>
- <DataSet xmlns="http://www.huaxuinfo.com/">
- <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
- <xs:complexType>
- <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="Table">
- <xs:complexType>
- <xs:sequence>
<xs:element name="FaultCauseID" type="xs:string" minOccurs="0" />
<xs:element name="FaultCauseName" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
- <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
- <NewDataSet xmlns="">
- <Table diffgr:id="Table1" msdata:rowOrder="0">
<FaultCauseID>14</FaultCauseID>
<FaultCauseName>关阀</FaultCauseName>
</Table>
- <Table diffgr:id="Table2" msdata:rowOrder="1">
<FaultCauseID>15</FaultCauseID>
<FaultCauseName>不读卡</FaultCauseName>
</Table>
- <Table diffgr:id="Table3" msdata:rowOrder="2">
<FaultCauseID>16</FaultCauseID>
<FaultCauseName>无显示</FaultCauseName>
</Table>
- <Table diffgr:id="Table4" msdata:rowOrder="3">
<FaultCauseID>17</FaultCauseID>
<FaultCauseName>漏水</FaultCauseName>
</Table>
- <Table diffgr:id="Table5" msdata:rowOrder="4">
<FaultCauseID>19</FaultCauseID>
<FaultCauseName>故障</FaultCauseName>
</Table>
- <Table diffgr:id="Table6" msdata:rowOrder="5">
<FaultCauseID>20</FaultCauseID>
<FaultCauseName>异常</FaultCauseName>
</Table>
- <Table diffgr:id="Table7" msdata:rowOrder="6">
<FaultCauseID>22</FaultCauseID>
<FaultCauseName>看不清</FaultCauseName>
</Table>
- <Table diffgr:id="Table8" msdata:rowOrder="7">
<FaultCauseID>23</FaultCauseID>
<FaultCauseName>表转</FaultCauseName>
</Table>
- <Table diffgr:id="Table9" msdata:rowOrder="8">
<FaultCauseID>24</FaultCauseID>
<FaultCauseName>表不走</FaultCauseName>
</Table>
- <Table diffgr:id="Table10" msdata:rowOrder="9">
<FaultCauseID>26</FaultCauseID>
<FaultCauseName>其他</FaultCauseName>
</Table>
- <Table diffgr:id="Table11" msdata:rowOrder="10">
<FaultCauseID>27</FaultCauseID>
<FaultCauseName>表冻</FaultCauseName>
</Table>
</NewDataSet>
</diffgr:diffgram>
</DataSet>
机器人 2011-05-23
  • 打赏
  • 举报
回复
跨语言的最好考虑用 RESTful 的方式。即直接通过HttpWebRequest方式调用的。

http://blog.csdn.net/fangxinggood/archive/2011/03/14/6247297.aspx
bigtree0906 2011-05-23
  • 打赏
  • 举报
回复
GetFaultCauseInfo

测试
若要使用 HTTP POST 协议对操作进行测试,请单击“调用”按钮。


SOAP 1.1
以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。

POST /VoiceServiceToWebSite/VoiceService.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.huaxuinfo.com/GetFaultCauseInfo"

<?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>
<GetFaultCauseInfo xmlns="http://www.huaxuinfo.com/" />
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?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>
<GetFaultCauseInfoResponse xmlns="http://www.huaxuinfo.com/">
<GetFaultCauseInfoResult>
<xsd:schema>schema</xsd:schema>xml</GetFaultCauseInfoResult>
</GetFaultCauseInfoResponse>
</soap:Body>
</soap:Envelope>
SOAP 1.2
以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。

POST /VoiceServiceToWebSite/VoiceService.asmx HTTP/1.1
Host: localhost
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetFaultCauseInfo xmlns="http://www.huaxuinfo.com/" />
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetFaultCauseInfoResponse xmlns="http://www.huaxuinfo.com/">
<GetFaultCauseInfoResult>
<xsd:schema>schema</xsd:schema>xml</GetFaultCauseInfoResult>
</GetFaultCauseInfoResponse>
</soap12:Body>
</soap12:Envelope>
HTTP POST
以下是 HTTP POST 请求和响应示例。所显示的占位符需替换为实际值。

POST /VoiceServiceToWebSite/VoiceService.asmx/GetFaultCauseInfo HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: length


HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<DataSet xmlns="http://www.huaxuinfo.com/">
<schema xmlns="http://www.w3.org/2001/XMLSchema">schema</schema>xml</DataSet>
bigtree0906 2011-05-23
  • 打赏
  • 举报
回复
To:Cp_Single
能不能说得详细一点。

其实Web Service我已经实现了,但其结果是DataSet的类型,在Delphi中就不知道如何调用了。
夕甜 2011-05-23
  • 打赏
  • 举报
回复
今天刚好用到了啊 不知道对不对啊 web Service
1.下好实体类
2.你先见一个web Serivce项目 写好接口
3.在接口中的方法GetFaulCause,然后实现接口的方法,实现你的功能
4.再进行发布 在别的项目中通过调用(客户端)
大致就是这些

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧