简体   繁体   English

调用web服务并在没有wsdl的情况下反序列化soap

[英]calling a webservice and deserializing soap without a wsdl

I have a vendor who doesn't seem to have a wsdl or is unwilling or doesn't know how to provide it. 我有一个供应商似乎没有wsdl或不愿意或不知道如何提供它。 They have a number of web services (technically they are JSPs that return soap messages) and I need to use about 10-15 of these to get my stuff done. 他们有许多Web服务(从技术上讲,它们是返回soap消息的JSP),我需要使用大约10-15个来完成我的工作。

Since there isn't a WSDL, I can't use the 'add web reference' functionality to generate proxy classes and such. 由于没有WSDL,我不能使用“添加Web引用”功能来生成代理类等。 I've gotten around this by using WebClient to make the calls and return the response as a string, but now I need to deserialize the response into client classes. 我通过使用WebClient进行调用并将响应作为字符串返回来解决这个问题,但现在我需要将响应反序列化为客户端类。

I've already made c# classes to match the xml that's returned, but I'm not sure how to deserialize from SOAP since there's so much xml noise. 我已经创建了c#类来匹配返回的xml,但我不确定如何从SOAP反序列化,因为有很多xml噪声。 I could strip the SOAP envelope tags and then use the XML serializer to deserialize to a List<SomeType> , but that seems really dirty. 我可以剥离SOAP信封标签,然后使用XML序列化程序反序列化为List<SomeType> ,但这看起来很脏。 Is there a nicer way? 有更好的方法吗?

Have you tried using SoapFormatter.Deserialize() for deserializing the response. 您是否尝试过使用SoapFormatter.Deserialize()来反序列化响应。 If so, this would be helpful. 如果是这样,这将是有帮助的。 http://msdn.microsoft.com/en-us/library/system.runtime.serialization.formatters.soap.soapformatter.deserialize(v=vs.71).aspx http://msdn.microsoft.com/en-us/library/system.runtime.serialization.formatters.soap.soapformatter.deserialize(v=vs.71).aspx

i published an article detailing on how to deserialize a complex xml. 我发表了一篇文章,详细介绍了如何对复杂的xml进行反序列化。

here is the link : http://blog.impact-works.com/2011/06/30/how-to-serializedeserialize-complex-xml-in-asp-net-c/ 这是链接: http//blog.impact-works.com/2011/06/30/how-to-serializedeserialize-complex-xml-in-asp-net-c/

hope it helps 希望能帮助到你

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM