Hi everyone,
I am having trouble with using this SoapExtension. I wanting to to
access the incoming xml to the webservice using it and this seems to
work. However then I get the following error returned to the client of
the WS: System.Net.WebException: The request failed with HTTP status
400: Bad Request. Any ideas what's wrong with the below:
public class InputSoapExtension : SoapExtension
{
Stream inStream = null;
MemoryStream outStream = null;
public override object GetInitializer(Type serviceType)
{
return null;
}
public override object GetInitializer(LogicalMethodInfo
methodInfo, SoapExtensionAttribute attribute)
{
return null;
}
public override void Initialize(object initializer)
{
return;
}
public override void ProcessMessage(SoapMessage message)
{
switch(message.Stage)
{
case SoapMessageStage.BeforeDeserialize:
case SoapMessageStage.AfterDeserialize:
Authenticate();
break;
case SoapMessageStage.BeforeSerialize:
case SoapMessageStage.AfterSerialize:
default:
break;
}
}
public override Stream ChainStream(Stream stream)
{
inStream = stream;
outStream = new MemoryStream();
return outStream;
}
private void Authenticate()
{
...
}
}
Chaitanya - 15 Mar 2007 09:51 GMT
In the BeforeDeserialize stage, copy the inStream to the outStream.
This is because you returned outStream in ChainStream function, the runtime
will expect the input/modified input to be present in the outstream to
deserialize. In your case, it is finding empty stream, because of which its
throwing the bad request error. Copying the stream should make it work fine..
> Hi everyone,
>
[quoted text clipped - 53 lines]
>
> }