472,958 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

Problems validating a SOAP request in a SOAP Extension

I am recieving the "The root element is missing" error from my soap extension
while attempting to validate an incoming SOAP message request. I suspect the
problem resides in the ChainStream method but I'm not sure. Below is a
water-downed version of the code that I'm working on. While debugging, I
noticed that if I pass an invalid SOAP request, the schema validation catches
it and throws the error appropriately. However, when I pass in a valid SOAP
request, the root element error is returned but not from the validation
handler. With this, I don't believe the problem is arising from the
XmlValidatingReader process. Any advise on how to resolve this issue is
appreciated.

public class MySolSoapExtension : SoapExtension
{
private Stream inputStream;
private Stream outputStream;
private bool bPostDeserialize;

public override object GetInitializer( Type serviceType )
{
return GetType();
}

public override object GetInitializer( LogicalMethodInfo methodInfo,
SoapExtensionAttribute attribute )
{
return null;
}

public override void Initialize( object initializer )
{
bPostDeserialize = false;
return;
}

public override Stream ChainStream( Stream stream )
{
//This flag will be set to true during the AfterDeserialize handler in
ProcessMessage()
if( !bPostDeserialize)
{
this.inputStream = stream;
this.outputStream = new MemoryStream();
this.inputStream.Position = 0;
return outputStream;
}

else
{
this.inputStream = new MemoryStream();
this.outputStream = stream;
this.outputStream.Position = 0;
return inputStream;
}
}
public override void ProcessMessage(SoapMessage msg)
{
switch(msg.Stage)
{
case SoapMessageStage.BeforeDeserialize:
try
{
// read incoming xml soap message
XmlTextReader tr = new XmlTextReader(new StreamReader(msg.Stream));

// validate xml
XmlValidatingReader vr = new XmlValidatingReader(tr);
vr.ValidationType = ValidationType.Schema;

// create a schema collection
XmlSchemaCollection xsc = new XmlSchemaCollection();
xsc.Add("http://schemas.xmlsoap.org/soap/envelope/", "envelope.xml");
xsc.Add("http://schemas.xmlsoap.org/soap/encoding/", "encoding.xml");

// load schema collection
vr.Schemas.Add(xsc);

// add validation event handler
vr.ValidationEventHandler += new
ValidationEventHandler(reader_ValidationEventHandl er);
while (vr.Read());
vr.Close();

bPostDeserialize = true;
}
finally
{
// reset stream position
msg.Stream.Position = 0;
}

break;
case SoapMessageStage.AfterDeserialize:
break;
case SoapMessageStage.BeforeSerialize:
break;
case SoapMessageStage.AfterSerialize:
break;
}
}

private static void reader_ValidationEventHandler(object sender,
ValidationEventArgs e)
{
throw new SoapException("Schema Error: " + e.Exception.Message, new
XmlQualifiedName("qname"));
}
}
Nov 23 '05 #1
0 2896

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Doe. | last post by:
Hi PHP gurus! Our team will be creating a web-application that must have an easy to use programmatic interface for our web-developer clients. The data transferred will primarily be taken from a...
0
by: ramas | last post by:
Hi, I am new to PHP scripting and i am trying to connect to a soap server (as mentioned below) using the SOAP extension comesup with PHP. Now my requirement is to add my HTTP header fields along...
4
by: pepcag | last post by:
I used http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconalteringsoapmessageusingsoapextensions.asp as a template to create a very simple web method with soap...
1
by: MarkoH | last post by:
I would like to be able to create string representation of SOAP message something like browsing with IE to ASMX page and trying to invoke some methods. There you can see (at the bottom, you know...
0
by: Matt Wood | last post by:
Hi, I have written a Web Service for a customer which expects a SOAP message with Document/Literal encoding, and uses RoutingStyle=SoapServiceRoutingStyle.RequestElement to route the SOAP body...
2
by: Frederik Vanderhaegen | last post by:
Hi, I'm writing a simple soap extension for a webservice I developed (without the use of an extension the webservice works perfect). The extension is registered through the web.config files of...
0
by: israelekpo | last post by:
phpPaypalPro version 0.2.0 Released The second version of phpPaypalPro has been released. phpPaypalPro is an object-oriented framework developed in PHP5 to integrate easily with the Website...
0
by: Florian Laws | last post by:
Hello, to work around an interoperability problem with the PHP5 SOAP extension, I'd like to modify the generate XML SOAP request. (as described in...
0
by: Patrick Brunmayr | last post by:
Hello I have a big Problem with validating a Soap Envelope. I have downloaded the xsd for a soap envelope from http://schemas.xmlsoap.org/soap/envelope/ The validation succeeds as lonng as i...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.