从 SoapHttpClientProtocol 生成的 MethodInfo 获取底层 WebResponse
我花了一段时间研究这个问题,但正在努力寻找任何有用的答案。
基本上我有一个之前从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此链接可能有用:
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