Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / March 2007

Tip: Looking for answers? Try searching our database.

SoapExtension using ChainStream causes HTTP 400 bad request

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rasika WIJAYARATNE - 09 Mar 2007 01:06 GMT
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]
>
>     }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.