S
Simon Kennedy
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.EndpointReference endPoint = ((Microsoft.Web.Services2.Messaging.SoapHttpRequestChannel)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
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.EndpointReference endPoint = ((Microsoft.Web.Services2.Messaging.SoapHttpRequestChannel)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