简体   繁体   English

SOAP xml客户端 - 使用Visual Studio 2010 c# - 如何?

[英]SOAP xml client - using Visual Studio 2010 c# - how?

I'm new to .NET world, yet have to use VStudio C# 2010 (.NET 4.0) to produce a client that requests data from a web service in SOAP Xml fashion. 我是.NET世界的新手,但必须使用VStudio C#2010(.NET 4.0)来生成以SOAP Xml方式从Web服务请求数据的客户端。 I've searched here for answers but got confused even more. 我在这里寻找答案,但更加困惑。 MSDN says that "Building XML Web Service Clients" is legacy for .NET 4.0, ie WSDL is legacy. MSDN表示“构建XML Web服务客户端”是.NET 4.0的遗产,即WSDL是遗留的。 Use "WCF" instead, they say. 他们说,使用“WCF”。 In WCF i got lost - too much and too vague. 在WCF我迷路了 - 太多太模糊了。 It must be simpler then that... And all examples that i could find on the web - they all use WSDL, "the legacy". 它必须更简单......以及我可以在网上找到的所有例子 - 它们都使用WSDL,“遗产”。

Here are the definitions of the service i need to use in order to obtain the data from the web service: 以下是为了从Web服务获取数据而需要使用的服务的定义:

request: 请求:

POST /catalog.asmx HTTP/1.1
Host: www.somewebsite.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "https://www.somewebsite.com/KeywordSearch"

<?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>
    <KeywordSearch xmlns="https://www.somewebsite.com/">
  <searchTerm>string</searchTerm>
  <resultsReturned>int</resultsReturned>
   </KeywordSearch>
  </soap:Body>
</soap:Envelope>

Response: 响应:

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>
    ...some stuff...
  </soap:Body>
</soap:Envelope>

So, what is the right, or at least most logical way to built this simple client? 那么,构建这个简单客户端的正确方法,或者至少是最合理的方式是什么? What tools/libraries/methodologies would you suggest to newbie (assuming VS 2010 C#, .NET 4.0 environment)? 您会向新手建议哪些工具/库/方法(假设是VS 2010 C#,.NET 4.0环境)?

If you have a WSDL/XSD to describe that service, or if you can navigate to an URL to grab that metadata, then WCF with basicHttpBinding would probably be your best bet. 如果您有一个WSDL / XSD来描述该服务,或者您可以导航到URL来获取该元数据,那么使用basicHttpBinding WCF可能是您最好的选择。 WSDL is definitely not "legacy" - if anything is legacy, then it's ASP.NET/ASMX webservices. WSDL绝对不是 “遗留” - 如果有任何遗产,那么它就是ASP.NET / ASMX webservices。

Given a WSDL/XSD or a URL where you can connect to, just do an Add Service Reference from within Visual Studio, and you should be up and running calling your WCF service in no time - trust me! 给定一个WSDL / XSD或您可以连接到的URL,只需在Visual Studio中执行Add Service Reference ,您就可以立即启动并运行调用您的WCF服务 - 相信我! You don't need to know all of WCF just to call a simple SOAP web service.... also, with WCF 4.0, lots of things - especially configuration - have been vastly improved and simplified. 并不需要了解所有WCF的只是调用一个简单的SOAP Web服务....还与WCF 4.0,很多东西-尤其是配置-已大大改进和简化。

As for resoures: there's the MSDN WCF Developer Center which has everything from beginner's tutorials to articles and sample code. 至于资源: MSDN WCF开发人员中心提供从初学者教程到文章和示例代码的所有内容。

Also, check out the screen cast library up on MSDN for some really useful, 10-15 minute chunks of information on just about any topic related to WCF you might be interested in. 另外,请查看MSDN上屏幕强制转换库,了解一些非常有用的10-15分钟信息块,其中包含与您可能感兴趣的WCF相关的任何主题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Visual Studio 2010中使用C#创建简单的SOAP服务器? - How do I create a simple SOAP server using C# in Visual Studio 2010? 在Visual Studio 2010中将压缩与C#Web服务客户端一起使用 - Using compression with C# webservice client in Visual Studio 2010 客户端和C#的Expression Web 4与Visual Studio 2010 - expression web 4 vs visual studio 2010 for client side and c# 使用Visual Studio 2010在C#中的两个不同计算机上运行的客户端和服务器之间的通信 - Communication between Client and Server running on two different machines in C# using Visual studio 2010 在Visual Studio 2010 C#项目中读取链接的xml文件 - Read a linked xml file in Visual Studio 2010 C# project 使用XML注释创建的C#文档在哪里(Visual Studio 2010)? - Where is C# documentation using XML comments created (Visual Studio 2010)? 如何在C#中制作可视的可重用类?(Visual Studio 2010) - How to make a visual reuasable class in C#?(Visual Studio 2010) 使用c#将Access数据库添加到Visual Studio 2010中的项目中 - Adding Access Database to Project in Visual Studio 2010 using c# 使用C#在Visual Studio 2010中使用预处理程序指令 - Using Preprocessor Directives in Visual Studio 2010 with C# 在Visual Studio 2010 C#中使用新的CultureInfo货币 - Using a new cultureinfo currency in Visual Studio 2010 C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM