具有自定义类输出参数的动态Web服务 [英] Dynamic Web service with custom class out parameter

查看:82
本文介绍了具有自定义类输出参数的动态Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

程序员,请帮忙,然后再撕掉头发!

我正在从具有输入和输出参数的wsdl文件动态创建Web服务.当这些参数是通用变量(即字符串,整数,字符...)时,我可以调用这些方法并获得我的信息.但是,我必须调用的Web服务具有作为自定义类的输出参数(我认为可能是从对象数组强制转换的).当我尝试在该Web服务上调用方法时,它说未找到该方法.我知道这是因为签名不正确,但是我不知道如何使用正确的签名来调用该方法.我可以获得自定义类的类型(因为我知道它应该是什么),但是当我尝试动态创建该类型的实例时,它仍然不起作用.我什至尝试使用对象类型都没有成功.这有意义吗?如果需要,我可以提供更多信息.

Fellow Programmers, please help before I tear out my hair!

I''m dynamically creating a web service from a wsdl file that has input and output parameters. When those parameters are generic variables (i.e strings, integers, chars...) I can call the methods and get my information just fine. However the webservices that I have to call have output parameters that are custom classes (possibly casted from object arrays, I think). When I try to invoke a method on that web service it says that the method is not found. I know that it''s because of an incorrect signature but I can''t figure out how to call the method with the correct signature. I can get the type of the custom class (because I know what it should be) but when I try to create an instance of that type dynamically it still doesn''t work. I''ve even tried using an object type with no success. Does this make sense? I can give more info if needed. Thank you in advance!

推荐答案

这似乎是一个愚蠢的问题,但是您在自己的应用程序中定义了那些自定义类型吗?本质上,您必须在连接的两边都装有一个程序集.
This may seem like a stupid question, but do you have those custom types defined in your own application? Essentially, you''d have to have an assembly with them in it on both sides of the connection.


使用通用对象实例将不起作用.如您所说,您需要实例化此自定义类型的对象.根据您所写的内容,您似乎无法正常工作.请发布一些代码,以便我们了解您的意思.

根据类型的复杂程度,动态创建类型可能并不容易.因此,您可能无法正确创建它.
Using a generic object instance will not work. As you say, you need to instantiate an object of this custom type. Based on what you wrote, it seems you could not get that working. Please post some code so we know what you mean.

Creating the type dynamically may not be trivial depending on how complex the type is. So you may not be creating it properly.


@John Simmons
我没有专门定义的自定义类型,因为我是在运行时创建Web服务的,这导致我进入下一条语句:
@Nishant Sivakumar
我尝试像这样实例化类型:
@John Simmons
I don''t have the custom type defined specifically because I''m creating the web service during runtime, which leads to me to my next statement:
@Nishant Sivakumar
I''ve tried instantiating the type like so:
Type type = invoker.webServiceAssembly.GetType("GetInventory_blocRow");
var instance = Activator.CreateInstance(type);


invoker.webServiceAssembly 是类型为System.Reflection.Assembly的已编译程序集.我正在创建为var,因为我不知道将其声明为什么.使用instance作为我的参数仍然会产生相同的错误:-(

似乎以这种方式创建类型确实可以工作,因为我可以在断点处看到此类的所有字段,但是这些方法仍然不喜欢它.

这是使用Reflector.Net
的已编译程序集的签名.


invoker.webServiceAssembly is the compiled assembly of type System.Reflection.Assembly. I''m creating as var because I don''t know what to declare it as. Using instance as my argument still yields the same error :-(

It seems that creating the type this way does work though because I can see all of the fields of this class during a breakpoint, but the methods still doesn''t like it.

Here is the signature of the compiled assembly using Reflector.Net

public string GetInventory(string site, string part, string wolot, out GetInventory_blocRow[] bloc);


这篇关于具有自定义类输出参数的动态Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆