WebService usage decision

H

hima

Hi,
I need to make a decision if company gonna use WebServices in out new project.

As I understand WebService uses serialization when passing parameters
from/to client. This meens that there is a lot of xml tags. Can somebody tell
me, does WebService sends this xml as is, or it does some kind of
trimming/restoring when communicating?

Does WebService use sessions, or it opens/closes every time client calls
web-method? If it does can it be used to store some data associoated with the
client's session?
 
P

Peter Kelcey

Hima,

By default, ASP.NET web services do not use the httpsessionstate
object. However, you can enable support of the session by using the
"EnableSession" attribute on your web method.

Example:
<WebMethod(EnableSession:=True)> _
Public Function HelloWorld2() As String
Return "HelloWorld"
End Function

Here's an excerpt from MSDN on what you may need to do on the client
side in order to support the use of the session.

An XML Web service client is uniquely identified by an HTTP cookie
returned by an XML Web service. In order for an XML Web service to
maintain session state for a client, the client must persist the
cookie. Clients can receive the HTTP cookie by creating a new instance
of CookieContainer and assigning that to the CookieContainer property
of the proxy class before calling the XML Web service method. If you
need to maintain session state beyond when the proxy class instance
goes out of scope, the client must persist the HTTP cookie between
calls to the XML Web service. For instance, a Web Forms client can
persist the HTTP cookie by saving the CookieContainer in its own
session state. Because not all XML Web services use session state and
thus clients are not always required to use the CookieContainer
property of a client proxy, the documentation for the XML Web service
should state whether session state is used.



With regards to the XML, it is sent as is. A SOAP request to a method
called "GetStockPrice" that takes a single parameter called "Price"
would look like this.

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.stock.org/stock">
<m:GetStockPrice>
<m:StockName>IBM</m:StockName>
</m:GetStockPrice>
</soap:Body>
</soap:Envelope>

Hope that helps

Peter Kelcey
 

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,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top