By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,376 Members | 1,566 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,376 IT Pros & Developers. It's quick & easy.

Using SOAP with .NET

P: n/a
Hi All,

Is it possible to support SOAP methods determined at runtime?
I thought that by implementing a class derived from 'SoapReceiver' and
registering the class within the web.config file of our ASP.NET project
might do the job but this seems to only support one way communication.
I can receive the soap call and its arguments but I'm unable to determine
how to return the result. All documentation points towards using 'SoapService'
and the 'SoapMethod' attribute but this requires knowledge of the SOAP action/method
at compile time, which we don't have. I have tried the following code but without success:

public class CustomSoapReceiver
: SoapReceiver
{
protected override void Receive(SoapEnvelope message)
{
if (message.Context.Addressing.Action == "Add")
{
// extract x and y values from incoming SOAP
// message
double x = XmlConvert.ToDouble(
message.SelectSingleNode("//x").InnerText);
double y = XmlConvert.ToDouble(
message.SelectSingleNode("//y").InnerText);
double result = x+y;

// do something with result
// send response message to original sender
SoapEnvelope replyMessage = new SoapEnvelope();
replyMessage.Context.Addressing.Action = message.Context.Addressing.Action;
replyMessage.CreateBody();
replyMessage.Body.InnerXml = String.Format("<{0}Response><result>{1}</result></{0}Response>",
message.Body.SelectSingleNode("*").LocalName, result);

// create SoapSender for the reply address and send message
Microsoft.Web.Services2.Addressing.EndpointReferen ce endPoint = ((Microsoft.Web.Services2.Messaging.SoapHttpReques tChannel)message.Context.Channel).RemoteEndpoint;
SoapSender responseSender = new SoapSender(endPoint);
responseSender.Send(replyMessage);
}
}
}

The 'Receive' method is suppose to take the x,y values, add them and return the result.
However the reply never seems to get back to the SOAP client. Is there a way to achieve my aim.

We are using 'VS.NET 2003' with the latest WSE2.

Thanks,

Simon. K
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Are you aware of Web Service support in .Net? This basically creates a "SOAP
server" for you and all that's needed is to create the methods in your
project language.

All the SOAP development is covered over so you needn't worry about it.

Dan.

"Simon Kennedy" <de*******@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi All,

Is it possible to support SOAP methods determined at runtime?
I thought that by implementing a class derived from 'SoapReceiver' and
registering the class within the web.config file of our ASP.NET project
might do the job but this seems to only support one way communication.
I can receive the soap call and its arguments but I'm unable to determine
how to return the result. All documentation points towards using
'SoapService'
and the 'SoapMethod' attribute but this requires knowledge of the SOAP
action/method
at compile time, which we don't have. I have tried the following code but
without success:

public class CustomSoapReceiver
: SoapReceiver
{
protected override void Receive(SoapEnvelope message)
{
if (message.Context.Addressing.Action == "Add")
{
// extract x and y values from incoming SOAP
// message
double x = XmlConvert.ToDouble(
message.SelectSingleNode("//x").InnerText);
double y = XmlConvert.ToDouble(
message.SelectSingleNode("//y").InnerText);
double result = x+y;

// do something with result
// send response message to original sender
SoapEnvelope replyMessage = new SoapEnvelope();
replyMessage.Context.Addressing.Action =
message.Context.Addressing.Action;
replyMessage.CreateBody();
replyMessage.Body.InnerXml =
String.Format("<{0}Response><result>{1}</result></{0}Response>",
message.Body.SelectSingleNode("*").LocalName, result);

// create SoapSender for the reply address and send
message
Microsoft.Web.Services2.Addressing.EndpointReferen ce
endPoint =
((Microsoft.Web.Services2.Messaging.SoapHttpReques tChannel)message.Context.Channel).RemoteEndpoint;
SoapSender responseSender = new SoapSender(endPoint);
responseSender.Send(replyMessage);
}
}
}

The 'Receive' method is suppose to take the x,y values, add them and
return the result.
However the reply never seems to get back to the SOAP client. Is there a
way to achieve my aim.

We are using 'VS.NET 2003' with the latest WSE2.

Thanks,

Simon. K

Nov 19 '05 #2

P: n/a
I'm aware of the Web Service support but I'm not sure how it can
be used to support methods/actions that I will not know about until
runtime. I know its easy to define a Web Service if you already know
what the interface/contract of the application is but if its user defined
(that is user based macros loaded at runtime) how do you do that?

Simon. K

Dan Bass wrote:
Are you aware of Web Service support in .Net? This basically creates a "SOAP
server" for you and all that's needed is to create the methods in your
project language.

All the SOAP development is covered over so you needn't worry about it.

Dan.

"Simon Kennedy" <de*******@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi All,

Is it possible to support SOAP methods determined at runtime?
I thought that by implementing a class derived from 'SoapReceiver' and
registering the class within the web.config file of our ASP.NET project
might do the job but this seems to only support one way communication.
I can receive the soap call and its arguments but I'm unable to determine
how to return the result. All documentation points towards using
'SoapService'
and the 'SoapMethod' attribute but this requires knowledge of the SOAP
action/method
at compile time, which we don't have. I have tried the following code but
without success:

public class CustomSoapReceiver
: SoapReceiver
{
protected override void Receive(SoapEnvelope message)
{
if (message.Context.Addressing.Action == "Add")
{
// extract x and y values from incoming SOAP
// message
double x = XmlConvert.ToDouble(
message.SelectSingleNode("//x").InnerText);
double y = XmlConvert.ToDouble(
message.SelectSingleNode("//y").InnerText);
double result = x+y;

// do something with result
// send response message to original sender
SoapEnvelope replyMessage = new SoapEnvelope();
replyMessage.Context.Addressing.Action =
message.Context.Addressing.Action;
replyMessage.CreateBody();
replyMessage.Body.InnerXml =
String.Format("<{0}Response><result>{1}</result></{0}Response>",
message.Body.SelectSingleNode("*").LocalName, result);

// create SoapSender for the reply address and send
message
Microsoft.Web.Services2.Addressing.EndpointReferen ce
endPoint =
((Microsoft.Web.Services2.Messaging.SoapHttpRequ estChannel)message.Context.Channel).RemoteEndpoint ;
SoapSender responseSender = new SoapSender(endPoint);
responseSender.Send(replyMessage);
}
}
}

The 'Receive' method is suppose to take the x,y values, add them and
return the result.
However the reply never seems to get back to the SOAP client. Is there a
way to achieve my aim.

We are using 'VS.NET 2003' with the latest WSE2.

Thanks,

Simon. K


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.