[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webservices

Consuming Web Service using .NET client without proxy

Aaron Aude

1/14/2003 7:31:00 PM

I would like to consume a web service (exposed as WSDL) in a .NET client
WITHOUT using a proxy to that service. This client will be asked to
call a web service by only knowing the following:

WSDL (and its location)
Method name
Input (and type)
Output (and type)

I have found sample code to automatically build a proxy class from a
WSDL. This works, but seems terribly inefficient for a client that
could potentially call hundreds of web services.

Thanks for the help
Aaron Aude



*** Sent via Developersdex http://www.develop... ***
Don't just participate in USENET...get rewarded for it!
1 Answer

Yasser Shohoud [MS]

1/14/2003 11:05:00 PM

0

Hi Aaron,

Here's a thought on this. If you don't want to incur the overhead of
loading the WSDL and building a proxy, you could simply use the Internet
request/response classes to make simple calls. You would need to format and
consume the XML in the SOAP envelopes but for for Document Literal Web
services the XML used is fairly straight forward and easy to wrap. The
following C# function sends a SOAP envelope to a web service and returns the
response envelope as a stringl:

public string SendSoapEnvelope(string sSoapEnv, string sUrl, string
sSoapAction)

{

// setup the request

WebRequest wReq = WebRequest.Create(sUrl);

HttpWebRequest httpReq = (HttpWebRequest) wReq ;

httpReq.Method = "POST" ;

httpReq.ContentType = "text/xml" ;

httpReq.Headers.Add ("SOAPAction: " + sSoapAction) ;

Stream sendStream = httpReq.GetRequestStream () ;

// put Request text into the request stream

StreamWriter strmWrtr = new StreamWriter(sendStream) ;

strmWrtr.Write (sSoapEnv) ;

strmWrtr.Close () ;

// make the request and get the response.

WebResponse wResp = null;

StreamReader strmRdr = null ;

string sResult ;

try

{

wResp = httpReq.GetResponse () ;

Stream respStrm = wResp.GetResponseStream () ;

strmRdr = new StreamReader (respStrm) ;

sResult = strmRdr.ReadToEnd () ;

}

catch (Exception Ex)

{

sResult = "Web Request returned error: " + Ex.Message ;

}


//return the response as a string;

return sResult ;

}



Hope this helps,

Martin

--
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Aaron Aude" <aaron.aude@cincinnati-it.com> wrote in message
news:#mF5ns$uCHA.616@TK2MSFTNGP11...
> I would like to consume a web service (exposed as WSDL) in a .NET client
> WITHOUT using a proxy to that service. This client will be asked to
> call a web service by only knowing the following:
>
> WSDL (and its location)
> Method name
> Input (and type)
> Output (and type)
>
> I have found sample code to automatically build a proxy class from a
> WSDL. This works, but seems terribly inefficient for a client that
> could potentially call hundreds of web services.
>
> Thanks for the help
> Aaron Aude
>
>
>
> *** Sent via Developersdex http://www.develop... ***
> Don't just participate in USENET...get rewarded for it!