views:

489

answers:

2

Hi all,

I'm involved in a project that would call a webservice dynamically.

I have figured out a way to call a webservice method that has no method parameters on it, but now what I need is for me to call web methods that have parameters on it.

Was wondering if there are good examples on how I could create a soap envelope and how I could include this in my HttpWebRequest?

Thank you so much!

Cheers, Ann

A: 

Is there any reason you want to generate SOAP envelopes manually and use HttpWebRequest to call a web service when you could generate a client proxy from the WSDL (using svcutil.exe or wsdl.exe) and let the framework do the heavy lifting for you?

Normally web services expose a contract that describes the operations you can invoke and the types that are involved allowing clients to discover it and use it.

Darin Dimitrov
Thank you for your answer.There is a reason why I need to do it manually... I'm creating a generic email generator/sending service that will pull out email data from different clients.I have considered generating a proxy from the WSDL, but I'm assuming that the downside of it is that if we try to add a new stakeholder web app that would need to send emails I might need to recompile the code again every single time. I might be wrong in this assumption, but if you could suggest any other way that I could do this, I would really appreciate it!Cheers!
mallows98
A: 

What about serialization with SoapFormatter?

SoapFormatter Class

You can also use strong typed classes by using interfaces and dynamicaly loaded assemblies via

Assembly a = Assembly.LoadFile("Path");

and you'll be able to "hot plug" new proxies or other types.

Jan Remunda
Will try doing this. Thanks for this! :)
mallows98
Hi mallows98,Were you able to solve this problem?I had a similar issue here:http://stackoverflow.com/questions/1609294/invoking-an-asp-net-web-service-method-via-an-http-request
Shoko
Hi Shoko,No, I've basically re-designed my code and used the standard web services pattern where you need to set your web service as dynamic and making sure that all method signatures that I will be accessing for my web services are of the same name. Reason that I've re-designed my code is because I was running out of time for the project and I need to do something fast.Hope this helps!
mallows98