Last post Jun 29, 2009 02:26 PM by l98_700r4
Jun 22, 2009 04:10 PM|l98_700r4|LINK
I'm having some difficulty with getting data from a .asmx webservice hosted in a windows forms application. I would like to essentially take the data received by the webservice and utilize it inside the main forms application (which contains a full .asmx host
based on the ServiceStation article from MSDN magazine).
Refering to the main windows form from inside the .asmx file did not work at all. So i probably need my compile my webservice directly into the forms application, but I have not yet found out how I can pass an instance of HttpListenerContext to a class / method
tagged with the WebService/Webmethod attribute.
I've found a number of examples of custom HttpHandlers that implement IHttpHandler, but they also describe the handler as being part of a dll located in a specific directory. I would like everything to occur inside my main application.
If I start out with an instance of HttpListenerContext, what would I do next to get the request forwarded to my webservice code? I don't really need the full .asmx functionality provided in the ServiceStation example, just the ability to host one simple webservice
inside my forms application and have all the webservice data accessible from the forms application. My webservice is also "One Way".
Unfortunately, I cannot make use of WSE and the SoapReceivers.Add() functionality as my client does not send the WS addressing headers in their soap messages (and they are very unlikely to change this)
Jun 28, 2009 11:18 PM|Nai-Dong Jin - MSFT|LINK
From your description, it seems that you want to add the web reference in your win form application, right?
I'm not sure what you mean by "involving your httphandler dll in your main application". First , httphandler is hosted in a server side application, but not in your client side application, so there's no way to involve your httphandler dll into your client
assembly. Second, you mentioned that you want to pass the HttpContext to your client via the webservice, I'm not quite sure why you want to achieve that, since HttpContext is used in server side enviroment, if what you want is to maintain the session state
while using WebService, you may refer the following article,
Jun 29, 2009 02:26 PM|l98_700r4|LINK
Thanks for responding.
Adding a web reference is not what I'm looking to do actually.
My application is essentially a server side application that is part of a larger windows forms application. The server (in my application) needs to receive one-way messages from a client on a different computer. The trouble I'm having is what to do if I
want my webmethod/webservice to be self contained in the application (instead of residing in .asmx files). Furthermore, I need to have all the form objects accessible from the webmethod itself (I.E. if my webmethod takes an array of strings as input, then
I'd want to be able to display the text strings in a text box in the forms application). If I try to do something like : "Form1.Textbox4.AppendText()" inside of a .asmx file, it doesn't work. This leads me to believe that my webmethod needs to be compiled
as part of my main server/WinForms application.
The only reason I mentioned IHttpHandler is because I thought installing a custom handler might be a way to do this.
Do I need to deserialize the soap message myself in order to do this?
I also have client side code in my application that was generated from wsdl.exe, when I invoke remote webmethods from my client side code, I get back data that is easily displayed in text boxes and I can treat it the same way I treat other variables that
are declared exclusively in the forms application.
So my application is acting as both a server and a client (and the remote computer it will be talking to also acts as both a server and a client)