Generic Webservice methods

R

Robby Valles

Hello,

I have a webservice with a static signature, that we have a custom
request and result class to handle different webmethods/services.

[WebMethod]
public MyResult Process( MyRequest r )

Currently, we have one proxy class generated and all webservice calls
point to this Process method. I am trying to figure out if we can have
mulitple web methods and call them dynamically by changing the
MethodName at runtime in the web proxy. Right now all we do is change
the url ex( localhost/search.asmx | localhost/createcustomer.asmx )
and use the same Process method. This works nicely as we dont have to
keep refreshing the web reference everytime we add a webservice.

When i try to change the webmethod name at runtime. I'm getting an
ArugmentException saying "GetUserList Web Service method name is not
valid.". This is happening in the BeforeSerialize method of
SoapHttpClientProtocol

at
System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize(WebRequest
request, String methodName, Object[] parameters)
at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
at MyService.Process(MyRequest r) in


Is there anyway I can call different webmethods at runtime without
knowing the name at compile time and without regenerating the proxy
class, since all request contracts are the same?

Thanks,

Robby
 
J

John Saunders [MVP]

Robby Valles said:
Hello,

I have a webservice with a static signature, that we have a custom
request and result class to handle different webmethods/services. ....

Is there anyway I can call different webmethods at runtime without
knowing the name at compile time and without regenerating the proxy
class, since all request contracts are the same?

Sure. Don't use proxy classes. Build and send the SOAP messages yourself.
 
R

Robby Valles

John,

Is there any way to do it and still use the proxy class?

Robby Valles
 
J

John Saunders [MVP]

John,

Is there any way to do it and still use the proxy class?


I don't even understand what you're asking, and I'm not sure that you do,
either.

Why do you need to be unaware of the methods you're calling until run time?
How will the users of your proxy class indicate which methods they want to
call, and with which parameters? How will they process the results?

I think you should tell us what you're trying to accomplish. What you've
described so far makes very little sense.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top