从 SoapHttpClientProtocol 生成的 MethodInfo 获取底层 WebResponse

发布于 2024-09-26 01:25:08 字数 653 浏览 1 评论 0原文

我花了一段时间研究这个问题,但正在努力寻找任何有用的答案。

基本上我有一个之前从 WSDL 编译的 SoapHttpClientProtocol。 然后,我从 clientProtocol 获取特定方法的 MethodInfo 并使用标准 Invoke 方法调用它。

您得到的只是来自作为对象的 Web 服务的响应。我想要做的是获取传回的实际 SOAP 响应,以便我可以进入实际的 XML。我见过一种非线程安全的方法来执行此操作,但这在这种情况下没有帮助。有谁知道这样做的方法。也许某种形式的代理?

如果有人可以提供帮助,将不胜感激。

Assembly assembly = GetLoadedAssembly(@"C:\Assembly.dll");
SoapHttpClientProtocol instanceType = (SoapHttpClientProtocol)assembly.CreateInstance("MyMethod");

MethodInfo method = instanceType.GetType().GetMethod(methodName);
object[] objParameters = {"a parameter"};
object response = method.Invoke(instanceType, objParameters);

I've spent a while looking at this but am struggling to get any useful answers.

Basically I have a SoapHttpClientProtocol that I've compiled from a WSDL previously.
I then get the MethodInfo for my particular method from the clientProtocol and Invoke it using the standard Invoke method.

What you get back is just the response from the web service cast as an object. What I want to do is get the actual SOAP response that is passed back so I can get into the actual XML. I have seen a non-thread safe way of doing this but that is no help in this case. Does anyone know a way of doing this. Maybe some form of proxy?

Would be extremely grateful if anyone could help.

Assembly assembly = GetLoadedAssembly(@"C:\Assembly.dll");
SoapHttpClientProtocol instanceType = (SoapHttpClientProtocol)assembly.CreateInstance("MyMethod");

MethodInfo method = instanceType.GetType().GetMethod(methodName);
object[] objParameters = {"a parameter"};
object response = method.Invoke(instanceType, objParameters);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风追烟花雨 2024-10-03 01:25:08

此链接可能有用:

http: //orbinary.com/blog/2010/01/getting-the-raw-soap-xml-sent-via-soaphttpclientprotocol/

提供的示例用于获取传出请求,但它似乎也适用于响应。

如果这不起作用(因为您正在反映),也许此方法可能适用于添加 SoapExtension:

http://blog.gatosoft.com/2005/07/31/ProgramaticallyRegisteringSoapExtensionsRedux.aspx

Microsoft 有一个 SoapExtension 本身的示例:

http://msdn.microsoft.com/en-us/library/bb552923(VS.90).aspx

This link might be useful:

http://orbinary.com/blog/2010/01/getting-the-raw-soap-xml-sent-via-soaphttpclientprotocol/

The example provided is for getting the outgoing request but it seems applicable also to the response.

If that doesn't work (since you're reflecting) perhaps this method might work for adding a SoapExtension:

http://blog.gatosoft.com/2005/07/31/ProgramaticallyRegisteringSoapExtensionsRedux.aspx

Microsoft has an example for the SoapExtension itself:

http://msdn.microsoft.com/en-us/library/bb552923(VS.90).aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文