Re: Inserting a SOAP Header in a client request

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Dilip Krishnan (dkrishnan_at_NOSPAM.geniant.com)
Date: 01/13/05


Date: Thu, 13 Jan 2005 13:45:04 -0800

Hello john,
   You really dont have to play around with bits and bytes. Every Soap based
Object has a LoadXml and GetXml that you can use in conjunction with a XmlTextReader/Writer.
So all you need to do is write to the chained stream using an xml writer.
But u do have to chain the stream to be able to alter the stream
HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com

> Sorry if my original post was not clear. Let me clarify the options I
> was exploring:
>
> Option 1: custom SoapHeader and modify the ws client proxy by hand to
> reference the new SoapHeader..
>
> Option 2: custom SoapExtension and modify the stream by hand via
> ChainStream().
>
> Option 3: custom Soap Extension and SoapHeader and modify the
> SoapMessage via ProcessMessage().
>
> So, it sounds like option 3 is not really an option. Option 2 means
> working with a byte stream instead of a Soap API. ChainStream() is
> the only place we can modify the message before serialization? I
> guess I'm still not quite clear on the distinction between
> ChainStream() and ProcessMessage().
>
> Given that this is all in the context of a web service request, I
> shouldn't have to work at the byte level to add a soap header to a
> soap message. I imagine the Stream could somehow be converted to a
> SoapMessage before adding the soap header but that would be
> inefficient given that it will be converted into a SoapMessage later
> in the call chain.
>
> WSE is something I will explore but for the time being this is what I
> am
> working with. I need to research Axis 1.1 support of WS-Security and
> compare
> it to .Net.
> The server side of this solution already exists and works for a
> different
> client implementation.
> Clean insertion of a custom soap header on the client side should be
> relatively painless. This is how it's done in Axis (Java):
>
> // setup authorization header
> SOAPHeaderElement authHeader = new SOAPHeaderElement( "",
> "AuthHeader" );
> MessageElement usernameElement = ( MessageElement )
> authHeader.addChildElement( "UserName" );
> MessageElement passwordElement = ( MessageElement )
> authHeader.addChildElement( "Password" );
> usernameElement.setObjectValue("jdoe");
> passwordElement.setObjectValue("password");
> call.addHeader( authHeader );
> John
>
> "Dilip Krishnan" wrote:
>
>> Hello john,
>> I dont see the difference in what you call the second option and the
>> third option. What you seem to be missing is overriding the chain
>> stream
>> and writing to the stream (which I gather you dont wish to do). The
>> problem
>> with your code is .. yes you're using the soap object model to add
>> the header
>> but you've failed to modify the stream by writing that information
>> back into
>> the stream. Also have you considered using WSE? and also are you sure
>> the
>> java service is not using WS-Security? If it is, you would need to
>> send standard
>> username tokens as opposed to a custom auth header
>> HTH
>> Regards,
>> Dilip Krishnan
>> MCAD, MCSD.net
>> dkrishnan at geniant dot com
>> http://www.geniant.com



Relevant Pages

  • Re: Inserting a SOAP Header in a client request
    ... custom SoapHeader and modify the ws client proxy by hand to ... custom SoapExtension and modify the stream by hand via ... custom Soap Extension and SoapHeader and modify the SoapMessage ...
    (microsoft.public.dotnet.framework.webservices)
  • Getting soap configuration to work
    ... ' Define a SOAP Extension that traces the SOAP request and SOAP response ... Private oldStream As Stream ... Public Overrides Function ChainStreamAs ... ByVal attribute As SoapExtensionAttribute) As Object ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Exchanging information
    ... The problem with serialised objects is both ends have to be running ... compress the stream, you get a quite compact binary stream. ... You must be able to recreate them after source code changes. ... SOAP helps you waste bandwidth if you have invested in companies like ...
    (comp.lang.java.help)
  • Re: Importing XML through .NET Web Service with VBA
    ... Dim objSClient As MSSOAPLib30.SoapClient30 ' soap object to access and expose web service interface ... ' Call the web service and load requested XML document in to MSXML DOM document structure ... ' save xml document from web service to stream ...
    (microsoft.public.excel.programming)
  • Re: Error on web service: "Server returned internal error 500"
    ... Why dont you use microsoft soap toolkit for intercepting the ... going on when web services correspond with each other (or other ... Stream sendStream = httpReq.GetRequestStream; ...
    (microsoft.public.dotnet.framework.webservices)