You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Jeff Ling <je...@google.com> on 2006/06/02 07:22:06 UTC

temp fix for NTML authentication & axiom serialization error

Hi guys,

I had to make my client work, so I digged into the code and "fixed" it. It's
just something for me to bypass the problem. Maybe someone could take a look
and provide a real fix?

Basically, first is "NTLM scheme can't use UsernamepasswordCredential"
error.
I changed the AbstractHttpSender.java. I use NTCredential when there is
"realm" defined. I am sure there is
        if (basicAuthentication.getRealm() == null)
        {
           defaultCredentials = new UsernamePasswordCredentials(
                basicAuthentication.getUsername(),
                basicAuthentication.getPassword());
        }else
        {
          defaultCredentials = new NTCredentials(
            basicAuthentication.getUsername (),
            basicAuthentication.getPassword(),
            basicAuthentication.getHost(),
            basicAuthentication.getRealm());
            agent.getState().setCredentials(new AuthScope(
              basicAuthentication.getHost(),
              basicAuthentication.getPort(),
              null), defaultCredentials);

            return;
        }


However, I still got this error.

ERROR [main] (WSS.java:53) - problem accessing the parser. Parser already
accessed!; nested exception is:
    javax.xml.stream.XMLStreamException: problem accessing the parser.
Parser already accessed!; nested exception is:
    org.apache.axis2.AxisFault: problem accessing the parser. Parser already
accessed!; nested exception is:
    javax.xml.stream.XMLStreamException: problem accessing the parser.
Parser already accessed!; nested exception is:
    org.apache.axis2.AxisFault: problem accessing the parser. Parser already
accessed!; nested exception is:
    javax.xml.stream.XMLStreamException: problem accessing the parser.
Parser already accessed!; nested exception is:
    org.apache.axis2.AxisFault: problem accessing the parser. Parser already
accessed!; nested exception is:
    javax.xml.stream.XMLStreamException: problem accessing the parser.
Parser already accessed!


The error came from the handshake (The second time call to
HttpMethodDirector.java inside HttpClient package)  After further digging, I
found it's not really Axis core module's issue. The error came from Axiom.
It failed in  StAXBuilder.java:

    public Object getParser() {
        if (parserAccessed) {
            throw new IllegalStateException(
                    "Parser already accessed!");
        }
I really don't want to find out why, but tried to see whether serializing
into a string would work. So I added the following call to
org.apache.axiom.om.impl.llom.OMElementImpl.java::internalSerialize();

              try
              {
              ByteArrayOutputStream buffer = new ByteArrayOutputStream();

              this.serialize(buffer);
              buffer.close();
              System.out.println(buffer.toString());
              }catch(Exception e)
              {
                System.out.println(e.getMessage());
              }

Magically, it "fixed" the problem! Now the authentication went through and
everything works fine!


Here I attached the two files. Can someone please look into the problem?

Re: [Axis2] temp fix for NTML authentication & axiom serialization error

Posted by Jeff Ling <je...@google.com>.
Ajith,

I tried it. The NTLM seems to be working. However, OM part is still not. Has
it been fixed in last night's build?

My "fix" of the OMElement doesn't work for some other situations. It throw
NULLPointer exception while processing some other returns. Shall I file
another bug?

Thanks,
Jeff

On 6/2/06, Ajith Ranabahu <aj...@gmail.com> wrote:
>
> hi,
> Ooops, hit the send by mistake. Please ignore the last post
>
> The reason for this is that the OMElement.serializeAndConsume() has
> been called twice
> It is not supposed to be! So my guess is the NTLM authentication pat
> has to call OMElement.build() first
>
> Ajith
>
> On 6/2/06, Ajith Ranabahu <aj...@gmail.com> wrote:
> > Hi,
> > The reason for this is that OMElement
> >
> > On 6/2/06, Paul Fremantle <pz...@gmail.com> wrote:
> > > Jeff
> > >
> > > Thanks for the update. We took a look at it (Saminda and me) and the
> > > update you made to AbstractHttpSender is great. We will add it into
> > > the core tree.
> > >
> > > However we still don't understand why you are getting into the second
> > > issue and the need to patch OMElementImpl.
> > >
> > > Can you please give us some more information about how you are using
> > > Axis2 and the scenario?
> > >
> > > Thanks,
> > > Paul
> > >
> > > --
> > > Paul Fremantle
> > > VP/Technology, WSO2 and OASIS WS-RX TC Co-chair
> > >
> > > http://bloglines.com/blog/paulfremantle
> > > paul@wso2.com
> > >
> > > "Oxygenating the Web Service Platform", www.wso2.com
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> > > For additional commands, e-mail: axis-dev-help@ws.apache.org
> > >
> > >
> >
> >
> > --
> > Ajith Ranabahu
> >
>
>
> --
> Ajith Ranabahu
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>

Re: [Axis2] temp fix for NTML authentication & axiom serialization error

Posted by Jeff Ling <je...@google.com>.
Hi Saminda,

Is this the perfect solution. The reason is that if you look at HttpClient
code, you will notice that whether to use Basic or NTLM, it is resolved at
runtime. (There is a message of "NTLM scheme selected" or something like
that.

Let's say the user specifies "domain/user, password", I guess the best
solution is to dynamically decide whether to use NTLM and Basic. In another
words, with the same input, based on handshake response from server, the
client decide whether to use NTCredential or UsernamePasswordCredential.

Another benefit is that if Kerberos or Digest is supported, then the user's
code doesn't have to change. Otherwise user (like me) has to write


HttpTransportProperties
>
> .DigestAuthentication dgiestAuthentication =
>                     new HttpTransportProperties().new
> DigestAuthentication();



Plus, it's the server admin who decides what auth scheme to use, or
simultaneous allow multiple. If the client code/configuration has to change,
it's very inconvenient.

Regards,
Jeff



On 6/9/06, Saminda Abeyruwan <sa...@opensource.lk> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Jeff, Dims, Paul and all,
>
> To do NTLM Authentication one has to do the following now,
>
> ...
> <snippet/>
>
> HttpTransportProperties.NTLMAuthentication ntlmAuthentication =
>                     new HttpTransportProperties().new
> NTLMAuthentication();
>
>             ntlmAuthentication.setUsername("axis2");
>             // other credentials.
>
>             options.setProperty(
>
> org.apache.axis2.transport.http.HTTPConstants.NTLM_AUTHENTICATION,
>                     ntlmAuthentication);
>
> ...
>
> To do Basic Authentication one has to do the following,
>
> ...
> <snippet/>
>
> HttpTransportProperties.BasicAuthentication basicAuthentication =
>                     new HttpTransportProperties().new
> BasicAuthentication();
>
>             basicAuthentication.setUsername("axis2");
>             basicAuthentication.setPassword("axis2");
>             options.setProperty(
>
> org.apache.axis2.transport.http.HTTPConstants.BASIC_AUTHENTICATION,
>                     basicAuthentication);
> ...
>
> Jeff, please try it and let us know the results. Will update the docs
> asap.
>
> Thank you
>
> Saminda
>
> Jeff Ling wrote:
> > Hi Dims,
> >
> > Thanks a lot!
> >
> > When would it be patched? And what's the plan for the next stable
> release?
> >
> > Thanks!
> >
> > Jeff
> >
> > On 6/8/06, *Davanum Srinivas * <davanum@gmail.com
> > <ma...@gmail.com>> wrote:
> >
> >     Jeff,
> >
> >     Yep. that's the one. Basically http client tries to send the data
> and
> >     when it fails tries to send it again. serializeAndConsume by design
> >     does not cache the information (does not build the om tree). This is
> >     good news just replacing one for the other. We'll take this account
> >     and may be add a flag for this behavior.
> >
> >     Thanks,
> >     dims
> >
> >     On 6/8/06, Jeff Ling <jeffling@google.com
> >     <ma...@google.com>> wrote:
> >     > Hi Paul,
> >     >
> >     > I assume you meant the
> >     >                     element.serializeAndConsume(bytesOut, format);
> >     > in         public byte[] writeBytes()
> >     >
> >     > right? No, that didn't work. However, following your lead, I
> >     changed the
> >     > same function in
> >     >
> >     >         private void handleOMOutput(OutputStream out, boolean
> >     doingMTOM)
> >     > throws XMLStreamException {
> >     >             format.setDoOptimize(doingMTOM);
> >     >
> >     >             element.serializeAndConsume (out, format);
> >     >         }
> >     >
> >     > to
> >     >
> >     >         private void handleOMOutput(OutputStream out, boolean
> >     doingMTOM)
> >     > throws XMLStreamException {
> >     >              format.setDoOptimize(doingMTOM);
> >     >              element.serialize(out, format);
> >     >          }
> >     >
> >     > That fixed it. Maybe we are using different versions so the line
> >     count is
> >     > different? Please confirm.
> >     >
> >     > This is great!
> >     >
> >     > Jeff
> >     >
> >     >
> >     > On 6/8/06, Paul Fremantle <pzfreo@gmail.com
> >     <ma...@gmail.com>> wrote:
> >     > > Jeff
> >     > >
> >     > > We have an idea :-) Can you help us test if its any good?
> >     > >
> >     > > Can you please try this fix:
> >     > >
> >     > > At line 194 in
> >     > org.apache.axis2.transport.http.SOAPOverHTTPSender.
> >     > >
> >     > > Please change
> >     > > element.serializeAndConsume (out, format); to
> >     > > element.serialize(out, format);
> >     > >
> >     > > If that works for you then we can craft a proper fix around
> this.
> >     > >
> >     > > Thanks
> >     > >
> >     > > Paul
> >     > >
> >     > > --
> >     > > Paul Fremantle
> >     > > VP/Technology, WSO2 and OASIS WS-RX TC Co-chair
> >     > >
> >     > > http://bloglines.com/blog/paulfremantle
> >     <http://bloglines.com/blog/paulfremantle>
> >     > > paul@wso2.com <ma...@wso2.com>
> >     > >
> >     > > "Oxygenating the Web Service Platform", www.wso2.com
> >     <http://www.wso2.com>
> >     > >
> >     >
> >     >
> >
> >
> >     --
> >     Davanum Srinivas : http://wso2.com/blogs/
> >
> >
> ---------------------------------------------------------------------
> >     To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> >     <ma...@ws.apache.org>
> >     For additional commands, e-mail: axis-dev-help@ws.apache.org
> >     <ma...@ws.apache.org>
> >
> >
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>
> iD4DBQFEiVBdYmklbLuW6wYRAuTXAJwK6LPFvAduT/GMRraFAA8EIRh0iwCY3DBi
> rnkK5RBPaT0ZdGDSlJTRVw==
> =S+ml
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>

Re: [Axis2] temp fix for NTML authentication & axiom serialization erro

Posted by Saminda Abeyruwan <sa...@gmail.com>.
Axis2 uses HttpClient's NTLM support. Your code snippet looks good, and
wonder if you have given the credentials according to
http://commons.apache.org/httpclient/authentication.html#NTLM

In addition to the above, you've need to set
auth.setAllowedRetry(true);

Please comment out
auth.setHost("hostname");
auth.setPort(80);

Saminda

On 8/20/07, hs <ha...@yahoo.com> wrote:
>
>
> Hi
>
> I am trying to use a webservice written in .net, for Sharepoint Portal.
> Am using axis2-1.3
> Have generated WebService client using eclipse pluggin
> In the generated class ServiceServiceSoapStub looks like this,
> //.....snippet
> OperationClient _operationClient =
> _serviceClient.createClient(_operations[0].getName())
>
> //.....
>
>     _serviceClient.addHeadersToEnvelope(env);
> _messageContext.setEnvelope(env);
>     HttpTransportProperties.Authenticator auth = new
> HttpTransportProperties.Authenticator();
>     auth.setUsername("username");
>     auth.setPassword("password");
>     auth.setDomain("domain");
>     auth.setHost("hostname");
>     auth.setPort(80);
>
> _operationClient.getOptions().setProperty(
> org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,auth);
>
>     _operationClient.addMessageContext(_messageContext);
>
> System.out.println(((HttpTransportProperties.Authenticator
> )_operationClient.getOptions().getProperty(
> org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE
> )).getUsername());
>        //execute the operation client
>         _operationClient.execute(true);
> // .....
>
> I am getting 401 exception
> org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
>         at
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(
> CommonsHTTPTransportSender.java:221)
>         at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:452)
>         at
> org.apache.axis2.description.OutInAxisOperationClient.send(
> OutInAxisOperation.java:330)
>         at
> org.apache.axis2.description.OutInAxisOperationClient.execute(
> OutInAxisOperation.java:294)
>         at
> com.microsoft.webservices.ServiceServiceSoapStub.FileUpload(
> ServiceServiceSoapStub.java:226)
>         at com.microsoft.webservices.SPSClient.main(SPSClient.java:99)
> Caused by: org.apache.axis2.AxisFault: Transport error: 401 Error:
> Unauthorized
>         at
>
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons
> (CommonsHTTPTransportSender.java:314)
>         at
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(
> CommonsHTTPTransportSender.java:201)
>
>
> Can we use options for NTML authentication and set it to OperationClient
> object?
> Or is there something I am missing out here :(
>
> Thanks,
> Harleen
>
>
> Saminda Abeyruwan wrote:
> >
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Hi Jeff, Dims, Paul and all,
> >
> > To do NTLM Authentication one has to do the following now,
> >
> > ...
> > <snippet/>
> >
> > HttpTransportProperties.NTLMAuthentication ntlmAuthentication =
> >                     new HttpTransportProperties().new
> > NTLMAuthentication();
> >
> >             ntlmAuthentication.setUsername("axis2");
> >             // other credentials.
> >
> >             options.setProperty(
> >
> > org.apache.axis2.transport.http.HTTPConstants.NTLM_AUTHENTICATION,
> >                     ntlmAuthentication);
> >
> > ...
> >
> > To do Basic Authentication one has to do the following,
> >
> > ...
> > <snippet/>
> >
> > HttpTransportProperties.BasicAuthentication basicAuthentication =
> >                     new HttpTransportProperties().new
> > BasicAuthentication();
> >
> >             basicAuthentication.setUsername("axis2");
> >             basicAuthentication.setPassword("axis2");
> >             options.setProperty(
> >
> > org.apache.axis2.transport.http.HTTPConstants.BASIC_AUTHENTICATION,
> >                     basicAuthentication);
> > ...
> >
> > Jeff, please try it and let us know the results. Will update the docs
> > asap.
> >
> > Thank you
> >
> > Saminda
> >
> > Jeff Ling wrote:
> >> Hi Dims,
> >>
> >> Thanks a lot!
> >>
> >> When would it be patched? And what's the plan for the next stable
> >> release?
> >>
> >> Thanks!
> >>
> >> Jeff
> >>
> >> On 6/8/06, *Davanum Srinivas * <davanum@gmail.com
> >> <ma...@gmail.com>> wrote:
> >>
> >>     Jeff,
> >>
> >>     Yep. that's the one. Basically http client tries to send the data
> and
> >>     when it fails tries to send it again. serializeAndConsume by design
> >>     does not cache the information (does not build the om tree). This
> is
> >>     good news just replacing one for the other. We'll take this account
> >>     and may be add a flag for this behavior.
> >>
> >>     Thanks,
> >>     dims
> >>
> >>     On 6/8/06, Jeff Ling <jeffling@google.com
> >>     <ma...@google.com>> wrote:
> >>     > Hi Paul,
> >>     >
> >>     > I assume you meant the
> >>     >                     element.serializeAndConsume(bytesOut,
> format);
> >>     > in         public byte[] writeBytes()
> >>     >
> >>     > right? No, that didn't work. However, following your lead, I
> >>     changed the
> >>     > same function in
> >>     >
> >>     >         private void handleOMOutput(OutputStream out, boolean
> >>     doingMTOM)
> >>     > throws XMLStreamException {
> >>     >             format.setDoOptimize(doingMTOM);
> >>     >
> >>     >             element.serializeAndConsume (out, format);
> >>     >         }
> >>     >
> >>     > to
> >>     >
> >>     >         private void handleOMOutput(OutputStream out, boolean
> >>     doingMTOM)
> >>     > throws XMLStreamException {
> >>     >              format.setDoOptimize(doingMTOM);
> >>     >              element.serialize(out, format);
> >>     >          }
> >>     >
> >>     > That fixed it. Maybe we are using different versions so the line
> >>     count is
> >>     > different? Please confirm.
> >>     >
> >>     > This is great!
> >>     >
> >>     > Jeff
> >>     >
> >>     >
> >>     > On 6/8/06, Paul Fremantle <pzfreo@gmail.com
> >>     <ma...@gmail.com>> wrote:
> >>     > > Jeff
> >>     > >
> >>     > > We have an idea :-) Can you help us test if its any good?
> >>     > >
> >>     > > Can you please try this fix:
> >>     > >
> >>     > > At line 194 in
> >>     > org.apache.axis2.transport.http.SOAPOverHTTPSender.
> >>     > >
> >>     > > Please change
> >>     > > element.serializeAndConsume (out, format); to
> >>     > > element.serialize(out, format);
> >>     > >
> >>     > > If that works for you then we can craft a proper fix around
> this.
> >>     > >
> >>     > > Thanks
> >>     > >
> >>     > > Paul
> >>     > >
> >>     > > --
> >>     > > Paul Fremantle
> >>     > > VP/Technology, WSO2 and OASIS WS-RX TC Co-chair
> >>     > >
> >>     > > http://bloglines.com/blog/paulfremantle
> >>     <http://bloglines.com/blog/paulfremantle>
> >>     > > paul@wso2.com <ma...@wso2.com>
> >>     > >
> >>     > > "Oxygenating the Web Service Platform", www.wso2.com
> >>     <http://www.wso2.com>
> >>     > >
> >>     >
> >>     >
> >>
> >>
> >>     --
> >>     Davanum Srinivas : http://wso2.com/blogs/
> >>
> >>
> ---------------------------------------------------------------------
> >>     To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> >>     <ma...@ws.apache.org>
> >>     For additional commands, e-mail: axis-dev-help@ws.apache.org
> >>     <ma...@ws.apache.org>
> >>
> >>
> >
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.1 (GNU/Linux)
> > Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
> >
> > iD4DBQFEiVBdYmklbLuW6wYRAuTXAJwK6LPFvAduT/GMRraFAA8EIRh0iwCY3DBi
> > rnkK5RBPaT0ZdGDSlJTRVw==
> > =S+ml
> > -----END PGP SIGNATURE-----
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-dev-help@ws.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/temp-fix-for-NTML-authentication---axiom-serialization-error-tf1720881.html#a12232670
> Sent from the Axis - Dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>


-- 
Saminda Abeyruwan

Software Engineer
WSO2 Inc. - www.wso2.org

Re: [Axis2] temp fix for NTML authentication & axiom serialization error

Posted by hs <ha...@yahoo.com>.
Hi 

I am trying to use a webservice written in .net, for Sharepoint Portal.
Am using axis2-1.3
Have generated WebService client using eclipse pluggin
In the generated class ServiceServiceSoapStub looks like this,
//.....snippet
 OperationClient _operationClient =
_serviceClient.createClient(_operations[0].getName())

//.....

    _serviceClient.addHeadersToEnvelope(env);
_messageContext.setEnvelope(env);			
    HttpTransportProperties.Authenticator auth = new
HttpTransportProperties.Authenticator();      
    auth.setUsername("username");
    auth.setPassword("password");
    auth.setDomain("domain");
    auth.setHost("hostname");
    auth.setPort(80);    
   
_operationClient.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,auth);
    
    _operationClient.addMessageContext(_messageContext);       
   
System.out.println(((HttpTransportProperties.Authenticator)_operationClient.getOptions().getProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE)).getUsername());
       //execute the operation client
        _operationClient.execute(true);
// .....

I am getting 401 exception
org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
	at
org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:221)
	at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:452)
	at
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:330)
	at
org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:294)
	at
com.microsoft.webservices.ServiceServiceSoapStub.FileUpload(ServiceServiceSoapStub.java:226)
	at com.microsoft.webservices.SPSClient.main(SPSClient.java:99)
Caused by: org.apache.axis2.AxisFault: Transport error: 401 Error:
Unauthorized
	at
org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:314)
	at
org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:201)


Can we use options for NTML authentication and set it to OperationClient
object?
Or is there something I am missing out here :(

Thanks,
Harleen


Saminda Abeyruwan wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi Jeff, Dims, Paul and all,
> 
> To do NTLM Authentication one has to do the following now,
> 
> ...
> <snippet/>
> 
> HttpTransportProperties.NTLMAuthentication ntlmAuthentication =
>                     new HttpTransportProperties().new
> NTLMAuthentication();
> 
>             ntlmAuthentication.setUsername("axis2");
>             // other credentials.
> 
>             options.setProperty(
> 
> org.apache.axis2.transport.http.HTTPConstants.NTLM_AUTHENTICATION,
>                     ntlmAuthentication);
> 
> ...
> 
> To do Basic Authentication one has to do the following,
> 
> ...
> <snippet/>
> 
> HttpTransportProperties.BasicAuthentication basicAuthentication =
>                     new HttpTransportProperties().new
> BasicAuthentication();
> 
>             basicAuthentication.setUsername("axis2");
>             basicAuthentication.setPassword("axis2");
>             options.setProperty(
> 
> org.apache.axis2.transport.http.HTTPConstants.BASIC_AUTHENTICATION,
>                     basicAuthentication);
> ...
> 
> Jeff, please try it and let us know the results. Will update the docs
> asap.
> 
> Thank you
> 
> Saminda
> 
> Jeff Ling wrote:
>> Hi Dims,
>> 
>> Thanks a lot!
>> 
>> When would it be patched? And what's the plan for the next stable
>> release?
>> 
>> Thanks!
>> 
>> Jeff
>> 
>> On 6/8/06, *Davanum Srinivas * <davanum@gmail.com
>> <ma...@gmail.com>> wrote:
>> 
>>     Jeff,
>> 
>>     Yep. that's the one. Basically http client tries to send the data and
>>     when it fails tries to send it again. serializeAndConsume by design
>>     does not cache the information (does not build the om tree). This is
>>     good news just replacing one for the other. We'll take this account
>>     and may be add a flag for this behavior.
>> 
>>     Thanks,
>>     dims
>> 
>>     On 6/8/06, Jeff Ling <jeffling@google.com
>>     <ma...@google.com>> wrote:
>>     > Hi Paul,
>>     >
>>     > I assume you meant the
>>     >                     element.serializeAndConsume(bytesOut, format);
>>     > in         public byte[] writeBytes()
>>     >
>>     > right? No, that didn't work. However, following your lead, I
>>     changed the
>>     > same function in
>>     >
>>     >         private void handleOMOutput(OutputStream out, boolean
>>     doingMTOM)
>>     > throws XMLStreamException {
>>     >             format.setDoOptimize(doingMTOM);
>>     >
>>     >             element.serializeAndConsume (out, format);
>>     >         }
>>     >
>>     > to
>>     >
>>     >         private void handleOMOutput(OutputStream out, boolean
>>     doingMTOM)
>>     > throws XMLStreamException {
>>     >              format.setDoOptimize(doingMTOM);
>>     >              element.serialize(out, format);
>>     >          }
>>     >
>>     > That fixed it. Maybe we are using different versions so the line
>>     count is
>>     > different? Please confirm.
>>     >
>>     > This is great!
>>     >
>>     > Jeff
>>     >
>>     >
>>     > On 6/8/06, Paul Fremantle <pzfreo@gmail.com
>>     <ma...@gmail.com>> wrote:
>>     > > Jeff
>>     > >
>>     > > We have an idea :-) Can you help us test if its any good?
>>     > >
>>     > > Can you please try this fix:
>>     > >
>>     > > At line 194 in
>>     > org.apache.axis2.transport.http.SOAPOverHTTPSender.
>>     > >
>>     > > Please change
>>     > > element.serializeAndConsume (out, format); to
>>     > > element.serialize(out, format);
>>     > >
>>     > > If that works for you then we can craft a proper fix around this.
>>     > >
>>     > > Thanks
>>     > >
>>     > > Paul
>>     > >
>>     > > --
>>     > > Paul Fremantle
>>     > > VP/Technology, WSO2 and OASIS WS-RX TC Co-chair
>>     > >
>>     > > http://bloglines.com/blog/paulfremantle
>>     <http://bloglines.com/blog/paulfremantle>
>>     > > paul@wso2.com <ma...@wso2.com>
>>     > >
>>     > > "Oxygenating the Web Service Platform", www.wso2.com
>>     <http://www.wso2.com>
>>     > >
>>     >
>>     >
>> 
>> 
>>     --
>>     Davanum Srinivas : http://wso2.com/blogs/
>> 
>>     ---------------------------------------------------------------------
>>     To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
>>     <ma...@ws.apache.org>
>>     For additional commands, e-mail: axis-dev-help@ws.apache.org
>>     <ma...@ws.apache.org>
>> 
>> 
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
> 
> iD4DBQFEiVBdYmklbLuW6wYRAuTXAJwK6LPFvAduT/GMRraFAA8EIRh0iwCY3DBi
> rnkK5RBPaT0ZdGDSlJTRVw==
> =S+ml
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/temp-fix-for-NTML-authentication---axiom-serialization-error-tf1720881.html#a12232670
Sent from the Axis - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [Axis2] temp fix for NTML authentication & axiom serialization error

Posted by Saminda Abeyruwan <sa...@opensource.lk>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Jeff, Dims, Paul and all,

To do NTLM Authentication one has to do the following now,

...
<snippet/>

HttpTransportProperties.NTLMAuthentication ntlmAuthentication =
                    new HttpTransportProperties().new NTLMAuthentication();

            ntlmAuthentication.setUsername("axis2");
            // other credentials.

            options.setProperty(

org.apache.axis2.transport.http.HTTPConstants.NTLM_AUTHENTICATION,
                    ntlmAuthentication);

...

To do Basic Authentication one has to do the following,

...
<snippet/>

HttpTransportProperties.BasicAuthentication basicAuthentication =
                    new HttpTransportProperties().new BasicAuthentication();

            basicAuthentication.setUsername("axis2");
            basicAuthentication.setPassword("axis2");
            options.setProperty(

org.apache.axis2.transport.http.HTTPConstants.BASIC_AUTHENTICATION,
                    basicAuthentication);
...

Jeff, please try it and let us know the results. Will update the docs asap.

Thank you

Saminda

Jeff Ling wrote:
> Hi Dims,
> 
> Thanks a lot!
> 
> When would it be patched? And what's the plan for the next stable release?
> 
> Thanks!
> 
> Jeff
> 
> On 6/8/06, *Davanum Srinivas * <davanum@gmail.com
> <ma...@gmail.com>> wrote:
> 
>     Jeff,
> 
>     Yep. that's the one. Basically http client tries to send the data and
>     when it fails tries to send it again. serializeAndConsume by design
>     does not cache the information (does not build the om tree). This is
>     good news just replacing one for the other. We'll take this account
>     and may be add a flag for this behavior.
> 
>     Thanks,
>     dims
> 
>     On 6/8/06, Jeff Ling <jeffling@google.com
>     <ma...@google.com>> wrote:
>     > Hi Paul,
>     >
>     > I assume you meant the
>     >                     element.serializeAndConsume(bytesOut, format);
>     > in         public byte[] writeBytes()
>     >
>     > right? No, that didn't work. However, following your lead, I
>     changed the
>     > same function in
>     >
>     >         private void handleOMOutput(OutputStream out, boolean
>     doingMTOM)
>     > throws XMLStreamException {
>     >             format.setDoOptimize(doingMTOM);
>     >
>     >             element.serializeAndConsume (out, format);
>     >         }
>     >
>     > to
>     >
>     >         private void handleOMOutput(OutputStream out, boolean
>     doingMTOM)
>     > throws XMLStreamException {
>     >              format.setDoOptimize(doingMTOM);
>     >              element.serialize(out, format);
>     >          }
>     >
>     > That fixed it. Maybe we are using different versions so the line
>     count is
>     > different? Please confirm.
>     >
>     > This is great!
>     >
>     > Jeff
>     >
>     >
>     > On 6/8/06, Paul Fremantle <pzfreo@gmail.com
>     <ma...@gmail.com>> wrote:
>     > > Jeff
>     > >
>     > > We have an idea :-) Can you help us test if its any good?
>     > >
>     > > Can you please try this fix:
>     > >
>     > > At line 194 in
>     > org.apache.axis2.transport.http.SOAPOverHTTPSender.
>     > >
>     > > Please change
>     > > element.serializeAndConsume (out, format); to
>     > > element.serialize(out, format);
>     > >
>     > > If that works for you then we can craft a proper fix around this.
>     > >
>     > > Thanks
>     > >
>     > > Paul
>     > >
>     > > --
>     > > Paul Fremantle
>     > > VP/Technology, WSO2 and OASIS WS-RX TC Co-chair
>     > >
>     > > http://bloglines.com/blog/paulfremantle
>     <http://bloglines.com/blog/paulfremantle>
>     > > paul@wso2.com <ma...@wso2.com>
>     > >
>     > > "Oxygenating the Web Service Platform", www.wso2.com
>     <http://www.wso2.com>
>     > >
>     >
>     >
> 
> 
>     --
>     Davanum Srinivas : http://wso2.com/blogs/
> 
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
>     <ma...@ws.apache.org>
>     For additional commands, e-mail: axis-dev-help@ws.apache.org
>     <ma...@ws.apache.org>
> 
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD4DBQFEiVBdYmklbLuW6wYRAuTXAJwK6LPFvAduT/GMRraFAA8EIRh0iwCY3DBi
rnkK5RBPaT0ZdGDSlJTRVw==
=S+ml
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [Axis2] temp fix for NTML authentication & axiom serialization error

Posted by Jeff Ling <je...@google.com>.
Hi Dims,

Thanks a lot!

When would it be patched? And what's the plan for the next stable release?

Thanks!

Jeff

On 6/8/06, Davanum Srinivas <da...@gmail.com> wrote:
>
> Jeff,
>
> Yep. that's the one. Basically http client tries to send the data and
> when it fails tries to send it again. serializeAndConsume by design
> does not cache the information (does not build the om tree). This is
> good news just replacing one for the other. We'll take this account
> and may be add a flag for this behavior.
>
> Thanks,
> dims
>
> On 6/8/06, Jeff Ling <je...@google.com> wrote:
> > Hi Paul,
> >
> > I assume you meant the
> >                     element.serializeAndConsume(bytesOut, format);
> > in         public byte[] writeBytes()
> >
> > right? No, that didn't work. However, following your lead, I changed the
> > same function in
> >
> >         private void handleOMOutput(OutputStream out, boolean doingMTOM)
> > throws XMLStreamException {
> >             format.setDoOptimize(doingMTOM);
> >
> >             element.serializeAndConsume(out, format);
> >         }
> >
> > to
> >
> >         private void handleOMOutput(OutputStream out, boolean doingMTOM)
> > throws XMLStreamException {
> >              format.setDoOptimize(doingMTOM);
> >              element.serialize(out, format);
> >          }
> >
> > That fixed it. Maybe we are using different versions so the line count
> is
> > different? Please confirm.
> >
> > This is great!
> >
> > Jeff
> >
> >
> > On 6/8/06, Paul Fremantle <pz...@gmail.com> wrote:
> > > Jeff
> > >
> > > We have an idea :-) Can you help us test if its any good?
> > >
> > > Can you please try this fix:
> > >
> > > At line 194 in
> > org.apache.axis2.transport.http.SOAPOverHTTPSender.
> > >
> > > Please change
> > > element.serializeAndConsume(out, format); to
> > > element.serialize(out, format);
> > >
> > > If that works for you then we can craft a proper fix around this.
> > >
> > > Thanks
> > >
> > > Paul
> > >
> > > --
> > > Paul Fremantle
> > > VP/Technology, WSO2 and OASIS WS-RX TC Co-chair
> > >
> > > http://bloglines.com/blog/paulfremantle
> > > paul@wso2.com
> > >
> > > "Oxygenating the Web Service Platform", www.wso2.com
> > >
> >
> >
>
>
> --
> Davanum Srinivas : http://wso2.com/blogs/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>

Re: [Axis2] temp fix for NTML authentication & axiom serialization error

Posted by Davanum Srinivas <da...@gmail.com>.
Jeff,

Yep. that's the one. Basically http client tries to send the data and
when it fails tries to send it again. serializeAndConsume by design
does not cache the information (does not build the om tree). This is
good news just replacing one for the other. We'll take this account
and may be add a flag for this behavior.

Thanks,
dims

On 6/8/06, Jeff Ling <je...@google.com> wrote:
> Hi Paul,
>
> I assume you meant the
>                     element.serializeAndConsume(bytesOut, format);
> in         public byte[] writeBytes()
>
> right? No, that didn't work. However, following your lead, I changed the
> same function in
>
>         private void handleOMOutput(OutputStream out, boolean doingMTOM)
> throws XMLStreamException {
>             format.setDoOptimize(doingMTOM);
>
>             element.serializeAndConsume(out, format);
>         }
>
> to
>
>         private void handleOMOutput(OutputStream out, boolean doingMTOM)
> throws XMLStreamException {
>              format.setDoOptimize(doingMTOM);
>              element.serialize(out, format);
>          }
>
> That fixed it. Maybe we are using different versions so the line count is
> different? Please confirm.
>
> This is great!
>
> Jeff
>
>
> On 6/8/06, Paul Fremantle <pz...@gmail.com> wrote:
> > Jeff
> >
> > We have an idea :-) Can you help us test if its any good?
> >
> > Can you please try this fix:
> >
> > At line 194 in
> org.apache.axis2.transport.http.SOAPOverHTTPSender.
> >
> > Please change
> > element.serializeAndConsume(out, format); to
> > element.serialize(out, format);
> >
> > If that works for you then we can craft a proper fix around this.
> >
> > Thanks
> >
> > Paul
> >
> > --
> > Paul Fremantle
> > VP/Technology, WSO2 and OASIS WS-RX TC Co-chair
> >
> > http://bloglines.com/blog/paulfremantle
> > paul@wso2.com
> >
> > "Oxygenating the Web Service Platform", www.wso2.com
> >
>
>


-- 
Davanum Srinivas : http://wso2.com/blogs/

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [Axis2] temp fix for NTML authentication & axiom serialization error

Posted by Jeff Ling <je...@google.com>.
Hi Paul,

I assume you meant the
                    element.serializeAndConsume(bytesOut, format);
in         public byte[] writeBytes()

right? No, that didn't work. However, following your lead, I changed the
same function in

        private void handleOMOutput(OutputStream out, boolean doingMTOM)
throws XMLStreamException {
            format.setDoOptimize(doingMTOM);
            element.serializeAndConsume(out, format);
        }

to

        private void handleOMOutput(OutputStream out, boolean doingMTOM)
throws XMLStreamException {
            format.setDoOptimize(doingMTOM);
            element.serialize(out, format);
        }

That fixed it. Maybe we are using different versions so the line count is
different? Please confirm.

This is great!

Jeff

On 6/8/06, Paul Fremantle <pz...@gmail.com> wrote:
>
> Jeff
>
> We have an idea :-) Can you help us test if its any good?
>
> Can you please try this fix:
>
> At line 194 in org.apache.axis2.transport.http.SOAPOverHTTPSender.
>
> Please change
> element.serializeAndConsume(out, format); to
> element.serialize(out, format);
>
> If that works for you then we can craft a proper fix around this.
>
> Thanks
>
> Paul
>
> --
> Paul Fremantle
> VP/Technology, WSO2 and OASIS WS-RX TC Co-chair
>
> http://bloglines.com/blog/paulfremantle
> paul@wso2.com
>
> "Oxygenating the Web Service Platform", www.wso2.com
>

Re: [Axis2] temp fix for NTML authentication & axiom serialization error

Posted by Paul Fremantle <pz...@gmail.com>.
Jeff

We have an idea :-) Can you help us test if its any good?

Can you please try this fix:

At line 194 in org.apache.axis2.transport.http.SOAPOverHTTPSender.

Please change
element.serializeAndConsume(out, format); to
element.serialize(out, format);

If that works for you then we can craft a proper fix around this.

Thanks

Paul

-- 
Paul Fremantle
VP/Technology, WSO2 and OASIS WS-RX TC Co-chair

http://bloglines.com/blog/paulfremantle
paul@wso2.com

"Oxygenating the Web Service Platform", www.wso2.com

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [Axis2] temp fix for NTML authentication & axiom serialization error

Posted by Jeff Ling <je...@google.com>.
Hi Ajith,

I still got the same error with the nightly build. Did you ever find what
the problem was?

Thanks,
Jeff

ERROR [main] (WSS.java:65) - problem accessing the parser. Parser already
accessed!; nested exception is:
    javax.xml.stream.XMLStreamException: problem accessing the parser.
Parser already accessed!; nested exception is:
    org.apache.axis2.AxisFault: problem accessing the parser. Parser already
accessed!; nested exception is:
    javax.xml.stream.XMLStreamException: problem accessing the parser.
Parser already accessed!; nested exception is:
    org.apache.axis2.AxisFault: problem accessing the parser. Parser already
accessed!; nested exception is:
    javax.xml.stream.XMLStreamException: problem accessing the parser.
Parser already accessed!; nested exception is:
    org.apache.axis2.AxisFault: problem accessing the parser. Parser already
accessed!; nested exception is:
    javax.xml.stream.XMLStreamException: problem accessing the parser.
Parser already accessed!
WARNING: Default charset GBK not supported, using ISO-8859-1 instead




On 6/2/06, Ajith Ranabahu <aj...@gmail.com> wrote:
>
> hi,
> Ooops, hit the send by mistake. Please ignore the last post
>
> The reason for this is that the OMElement.serializeAndConsume() has
> been called twice
> It is not supposed to be! So my guess is the NTLM authentication pat
> has to call OMElement.build() first
>
> Ajith
>
> On 6/2/06, Ajith Ranabahu <aj...@gmail.com> wrote:
> > Hi,
> > The reason for this is that OMElement
> >
> > On 6/2/06, Paul Fremantle <pz...@gmail.com> wrote:
> > > Jeff
> > >
> > > Thanks for the update. We took a look at it (Saminda and me) and the
> > > update you made to AbstractHttpSender is great. We will add it into
> > > the core tree.
> > >
> > > However we still don't understand why you are getting into the second
> > > issue and the need to patch OMElementImpl.
> > >
> > > Can you please give us some more information about how you are using
> > > Axis2 and the scenario?
> > >
> > > Thanks,
> > > Paul
> > >
> > > --
> > > Paul Fremantle
> > > VP/Technology, WSO2 and OASIS WS-RX TC Co-chair
> > >
> > > http://bloglines.com/blog/paulfremantle
> > > paul@wso2.com
> > >
> > > "Oxygenating the Web Service Platform", www.wso2.com
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> > > For additional commands, e-mail: axis-dev-help@ws.apache.org
> > >
> > >
> >
> >
> > --
> > Ajith Ranabahu
> >
>
>
> --
> Ajith Ranabahu
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>

Re: [Axis2] temp fix for NTML authentication & axiom serialization error

Posted by Jeff Ling <je...@google.com>.
Hi Ajith and Paul,

Yes, it sounds right: Parser was accessed when not supposed to be, so a
calling sequence might be the reason.

Thanks for taking care of this so promptly. Let me know if there is anything
else I can help with. (Such as a particular build I can test?)

Jeff

On 6/2/06, Ajith Ranabahu <aj...@gmail.com> wrote:
>
> hi,
> Ooops, hit the send by mistake. Please ignore the last post
>
> The reason for this is that the OMElement.serializeAndConsume() has
> been called twice
> It is not supposed to be! So my guess is the NTLM authentication pat
> has to call OMElement.build() first
>
> Ajith
>
> On 6/2/06, Ajith Ranabahu <aj...@gmail.com> wrote:
> > Hi,
> > The reason for this is that OMElement
> >
> > On 6/2/06, Paul Fremantle <pz...@gmail.com> wrote:
> > > Jeff
> > >
> > > Thanks for the update. We took a look at it (Saminda and me) and the
> > > update you made to AbstractHttpSender is great. We will add it into
> > > the core tree.
> > >
> > > However we still don't understand why you are getting into the second
> > > issue and the need to patch OMElementImpl.
> > >
> > > Can you please give us some more information about how you are using
> > > Axis2 and the scenario?
> > >
> > > Thanks,
> > > Paul
> > >
> > > --
> > > Paul Fremantle
> > > VP/Technology, WSO2 and OASIS WS-RX TC Co-chair
> > >
> > > http://bloglines.com/blog/paulfremantle
> > > paul@wso2.com
> > >
> > > "Oxygenating the Web Service Platform", www.wso2.com
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> > > For additional commands, e-mail: axis-dev-help@ws.apache.org
> > >
> > >
> >
> >
> > --
> > Ajith Ranabahu
> >
>
>
> --
> Ajith Ranabahu
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>

Re: [Axis2] temp fix for NTML authentication & axiom serialization error

Posted by Ajith Ranabahu <aj...@gmail.com>.
hi,
Ooops, hit the send by mistake. Please ignore the last post

The reason for this is that the OMElement.serializeAndConsume() has
been called twice
It is not supposed to be! So my guess is the NTLM authentication pat
has to call OMElement.build() first

Ajith

On 6/2/06, Ajith Ranabahu <aj...@gmail.com> wrote:
> Hi,
> The reason for this is that OMElement
>
> On 6/2/06, Paul Fremantle <pz...@gmail.com> wrote:
> > Jeff
> >
> > Thanks for the update. We took a look at it (Saminda and me) and the
> > update you made to AbstractHttpSender is great. We will add it into
> > the core tree.
> >
> > However we still don't understand why you are getting into the second
> > issue and the need to patch OMElementImpl.
> >
> > Can you please give us some more information about how you are using
> > Axis2 and the scenario?
> >
> > Thanks,
> > Paul
> >
> > --
> > Paul Fremantle
> > VP/Technology, WSO2 and OASIS WS-RX TC Co-chair
> >
> > http://bloglines.com/blog/paulfremantle
> > paul@wso2.com
> >
> > "Oxygenating the Web Service Platform", www.wso2.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-dev-help@ws.apache.org
> >
> >
>
>
> --
> Ajith Ranabahu
>


-- 
Ajith Ranabahu

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [Axis2] temp fix for NTML authentication & axiom serialization error

Posted by Ajith Ranabahu <aj...@gmail.com>.
Hi,
The reason for this is that OMElement

On 6/2/06, Paul Fremantle <pz...@gmail.com> wrote:
> Jeff
>
> Thanks for the update. We took a look at it (Saminda and me) and the
> update you made to AbstractHttpSender is great. We will add it into
> the core tree.
>
> However we still don't understand why you are getting into the second
> issue and the need to patch OMElementImpl.
>
> Can you please give us some more information about how you are using
> Axis2 and the scenario?
>
> Thanks,
> Paul
>
> --
> Paul Fremantle
> VP/Technology, WSO2 and OASIS WS-RX TC Co-chair
>
> http://bloglines.com/blog/paulfremantle
> paul@wso2.com
>
> "Oxygenating the Web Service Platform", www.wso2.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>


-- 
Ajith Ranabahu

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [Axis2] temp fix for NTML authentication & axiom serialization error

Posted by Paul Fremantle <pz...@gmail.com>.
Jeff

Thanks for the update. We took a look at it (Saminda and me) and the
update you made to AbstractHttpSender is great. We will add it into
the core tree.

However we still don't understand why you are getting into the second
issue and the need to patch OMElementImpl.

Can you please give us some more information about how you are using
Axis2 and the scenario?

Thanks,
Paul

-- 
Paul Fremantle
VP/Technology, WSO2 and OASIS WS-RX TC Co-chair

http://bloglines.com/blog/paulfremantle
paul@wso2.com

"Oxygenating the Web Service Platform", www.wso2.com

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re:[Axis2] temp fix for NTML authentication & axiom serialization error

Posted by Saminda Abeyruwan <sa...@opensource.lk>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Jeff,

Thank you for testing out the NTLM authentication scheme on Axis2. Will
apply the patch asap. Please be kind enough to test it out and let us
know the results.

Thank you

Saminda

Jeff Ling wrote:
> Hi guys,
> 
> I had to make my client work, so I digged into the code and "fixed" it.
> It's just something for me to bypass the problem. Maybe someone could
> take a look and provide a real fix?
> 
> Basically, first is "NTLM scheme can't use UsernamepasswordCredential"
> error.
> I changed the AbstractHttpSender.java. I use NTCredential when there is
> "realm" defined. I am sure there is
>         if (basicAuthentication.getRealm() == null)
>         {
>            defaultCredentials = new UsernamePasswordCredentials(
>                 basicAuthentication.getUsername(),
>                 basicAuthentication.getPassword());
>         }else
>         {
>           defaultCredentials = new NTCredentials(
>             basicAuthentication.getUsername (),
>             basicAuthentication.getPassword(),
>             basicAuthentication.getHost(),
>             basicAuthentication.getRealm());
>             agent.getState().setCredentials(new AuthScope(
>               basicAuthentication.getHost(),
>               basicAuthentication.getPort(),
>               null), defaultCredentials);
>            
>             return;
>         }
> 
> 
> However, I still got this error.
> 
> ERROR [main] (WSS.java:53) - problem accessing the parser. Parser
> already accessed!; nested exception is:
>     javax.xml.stream.XMLStreamException: problem accessing the parser.
> Parser already accessed!; nested exception is:
>     org.apache.axis2.AxisFault: problem accessing the parser. Parser
> already accessed!; nested exception is:
>     javax.xml.stream.XMLStreamException: problem accessing the parser.
> Parser already accessed!; nested exception is:
>     org.apache.axis2.AxisFault: problem accessing the parser. Parser
> already accessed!; nested exception is:
>     javax.xml.stream.XMLStreamException: problem accessing the parser.
> Parser already accessed!; nested exception is:
>     org.apache.axis2.AxisFault: problem accessing the parser. Parser
> already accessed!; nested exception is:
>     javax.xml.stream.XMLStreamException: problem accessing the parser.
> Parser already accessed!
> 
> 
> The error came from the handshake (The second time call to
> HttpMethodDirector.java inside HttpClient package)  After further
> digging, I found it's not really Axis core module's issue. The error
> came from Axiom. It failed in  StAXBuilder.java:
> 
>     public Object getParser() {
>         if (parserAccessed) {
>             throw new IllegalStateException(
>                     "Parser already accessed!");
>         }
> I really don't want to find out why, but tried to see whether
> serializing into a string would work. So I added the following call to
> org.apache.axiom.om.impl.llom.OMElementImpl.java::internalSerialize();
> 
>               try
>               {
>               ByteArrayOutputStream buffer = new ByteArrayOutputStream();
>              
>               this.serialize(buffer);
>               buffer.close();
>               System.out.println(buffer.toString());
>               }catch(Exception e)
>               {
>                 System.out.println(e.getMessage());
>               }
> 
> Magically, it "fixed" the problem! Now the authentication went through
> and everything works fine!
> 
> 
> Here I attached the two files. Can someone please look into the problem?
> 
> 
> 
> ------------------------------------------------------------------------
> 
> /*
>  * Copyright 2004,2005 The Apache Software Foundation.
>  *
>  * Licensed under the Apache License, Version 2.0 (the "License");
>  * you may not use this file except in compliance with the License.
>  * You may obtain a copy of the License at
>  *
>  *      http://www.apache.org/licenses/LICENSE-2.0
>  *
>  * Unless required by applicable law or agreed to in writing, software
>  * distributed under the License is distributed on an "AS IS" BASIS,
>  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  * See the License for the specific language governing permissions and
>  * limitations under the License.
>  */
> 
> package org.apache.axiom.om.impl.llom;
> 
> import org.apache.axiom.om.OMAbstractFactory;
> import org.apache.axiom.om.OMAttribute;
> import org.apache.axiom.om.OMConstants;
> import org.apache.axiom.om.OMContainer;
> import org.apache.axiom.om.OMElement;
> import org.apache.axiom.om.OMException;
> import org.apache.axiom.om.OMFactory;
> import org.apache.axiom.om.OMNamespace;
> import org.apache.axiom.om.OMNode;
> import org.apache.axiom.om.OMText;
> import org.apache.axiom.om.OMXMLParserWrapper;
> import org.apache.axiom.om.impl.OMContainerEx;
> import org.apache.axiom.om.impl.OMNodeEx;
> import org.apache.axiom.om.impl.builder.StAXOMBuilder;
> import org.apache.axiom.om.impl.traverse.OMChildElementIterator;
> import org.apache.axiom.om.impl.traverse.OMChildrenIterator;
> import org.apache.axiom.om.impl.traverse.OMChildrenQNameIterator;
> import org.apache.axiom.om.impl.util.EmptyIterator;
> import org.apache.axiom.om.impl.util.OMSerializerUtil;
> import org.apache.axiom.om.util.ElementHelper;
> 
> import java.io.ByteArrayOutputStream;
> import java.util.HashMap;
> import java.util.Iterator;
> 
> import javax.xml.namespace.QName;
> import javax.xml.stream.XMLStreamConstants;
> import javax.xml.stream.XMLStreamException;
> import javax.xml.stream.XMLStreamReader;
> import javax.xml.stream.XMLStreamWriter;
> 
> /**
>  * Class OMElementImpl
>  */
> public class OMElementImpl extends OMNodeImpl
>         implements OMElement, OMConstants, OMContainerEx {
>     /**
>      * Field ns
>      */
>     protected OMNamespace ns;
> 
>     /**
>      * Field localName
>      */
>     protected String localName;
>     /**
>      * Field firstChild
>      */
>     protected OMNode firstChild;
> 
>     /**
>      * Field namespaces
>      */
>     protected HashMap namespaces = null;
> 
>     /**
>      * Field attributes
>      */
>     protected HashMap attributes = null;
> 
>     /**
>      * Field noPrefixNamespaceCounter
>      */
>     protected int noPrefixNamespaceCounter = 0;
>     protected OMNode lastChild;
>     private int lineNumber;
>     private static final EmptyIterator EMPTY_ITERATOR = new EmptyIterator();
> 
>     /**
>      * Constructor OMElementImpl.
>      */
>     public OMElementImpl(String localName, OMNamespace ns, OMContainer parent,
>                          OMXMLParserWrapper builder, OMFactory factory) {
>         super(parent, factory);
>         this.localName = localName;
>         if (ns != null) {
>             setNamespace(ns);
>         }
>         this.builder = builder;
>         firstChild = null;
>     }
> 
> 
>     /**
>      * Constructor OMElementImpl.
>      */
>     public OMElementImpl(String localName, OMNamespace ns, OMFactory factory) {
>         this(localName, ns, null, factory);
>     }
> 
>     /**
>      * This is the basic constructor for OMElement. All the other constructors
>      * depends on this.
>      *
>      * @param localName - this MUST always be not null
>      * @param ns        - can be null
>      * @param parent    - this should be an OMContainer
>      * @param factory   - factory that created this OMElement
>      */
>     public OMElementImpl(String localName, OMNamespace ns, OMContainer parent,
>                          OMFactory factory) {
>         super(parent, factory);
>         if (localName == null || localName.trim().length() == 0) {
>             throw new OMException("localname can not be null or empty");
>         }
>         this.localName = localName;
>         this.done = true;
>         if (ns != null) {
>             setNamespace(ns);
>         }
>     }
> 
>     /**
>      * It is assumed that the QName passed contains, at least, the localName for this element.
>      *
>      * @param qname - this should be valid qname according to javax.xml.namespace.QName
>      * @throws OMException
>      */
>     public OMElementImpl(QName qname, OMContainer parent, OMFactory factory)
>             throws OMException {
>         this(qname.getLocalPart(), null, parent, factory);
>         this.ns = handleNamespace(qname);
>     }
> 
>     /**
>      * Method handleNamespace.
>      */
>     OMNamespace handleNamespace(QName qname) {
>         OMNamespace ns = null;
> 
>         // first try to find a namespace from the scope
>         String namespaceURI = qname.getNamespaceURI();
>         if (namespaceURI != null && namespaceURI.length() > 0) {
>             ns = findNamespace(qname.getNamespaceURI(),
>                     qname.getPrefix());
> 
>             /**
>              * What is left now is
>              *  1. nsURI = null & parent != null, but ns = null
>              *  2. nsURI != null, (parent doesn't have an ns with given URI), but ns = null
>              */
>             if (ns == null) {
>                 String prefix = qname.getPrefix();
>                 if ("".equals(prefix)) {
>                     prefix = OMSerializerUtil.getNextNSPrefix();
>                 }
>                 ns = declareNamespace(namespaceURI, prefix);
>             }
>             if (ns != null) {
>                 this.ns = ns;
>             }
>         } else
> 
>         {
>             // no namespace URI in the given QName. No need to bother about this ??
>         }
> 
>         return ns;
>     }
> 
>     /**
>      * Method handleNamespace.
>      *
>      * @return Returns namespace.
>      */
>     private OMNamespace handleNamespace(OMNamespace ns) {
>         OMNamespace namespace = findNamespace(ns.getName(),
>                 ns.getPrefix());
>         if (namespace == null) {
>             namespace = declareNamespace(ns);
>         }
>         return namespace;
>     }
> 
>     /**
>      * Adds child to the element. One can decide whether to append the child or to add to the
>      * front of the children list.
>      */
>     public void addChild(OMNode child) {
>         addChild((OMNodeImpl) child);
>     }
> 
>     /**
>      * Searches for children with a given QName and returns an iterator to traverse through
>      * the OMNodes.
>      * This QName can contain any combination of prefix, localname and URI.
>      *
>      * @throws OMException
>      */
>     public Iterator getChildrenWithName(QName elementQName) {
>         return new OMChildrenQNameIterator(getFirstOMChild(),
>                 elementQName);
>     }
> 
>     /**
>      * Method getFirstChildWithName.
>      *
>      * @throws OMException
>      */
>     public OMElement getFirstChildWithName(QName elementQName) throws OMException {
>         OMChildrenQNameIterator omChildrenQNameIterator =
>                 new OMChildrenQNameIterator(getFirstOMChild(),
>                         elementQName);
>         OMNode omNode = null;
>         if (omChildrenQNameIterator.hasNext()) {
>             omNode = (OMNode) omChildrenQNameIterator.next();
>         }
> 
>         return ((omNode != null) && (OMNode.ELEMENT_NODE == omNode.getType())) ?
>                 (OMElement) omNode : null;
> 
>     }
> 
>     /**
>      * Method addChild.
>      */
>     private void addChild(OMNodeImpl child) {
>         //the order of these statements is VERY important
>         //Since setting the parent has a detach method inside
>         //it strips down all the rerefences to siblings.
>         //setting the siblings should take place AFTER setting the parent
> 
>         child.setParent(this);
> 
>         if (firstChild == null) {
>             firstChild = child;
>             child.previousSibling = null;
>         } else {
>             child.previousSibling = (OMNodeImpl) lastChild;
>             ((OMNodeImpl) lastChild).nextSibling = child;
>         }
> 
>         child.nextSibling = null;
>         lastChild = child;
> 
>     }
> 
>     /**
>      * Gets the next sibling. This can be an OMAttribute or OMText or
>      * OMELement for others.
>      *
>      * @throws OMException
>      */
>     public OMNode getNextOMSibling() throws OMException {
>         while (!done) {
>             int token = builder.next();
>             if (token == XMLStreamConstants.END_DOCUMENT) {
>                 throw new OMException();
>             }
>         }
>         return super.getNextOMSibling();
>     }
> 
>     /**
>      * Returns a collection of this element. Children can be of types OMElement, OMText.
>      *
>      * @return Returns children.
>      */
>     public Iterator getChildren() {
>         return new OMChildrenIterator(getFirstOMChild());
>     }
> 
>     /**
>      * Returns a filtered list of children - just the elements.
>      *
>      * @return Returns an iterator of the child elements.
>      */
>     public Iterator getChildElements() {
>         return new OMChildElementIterator(getFirstElement());
>     }
> 
>     /**
>      * Creates a namespace in the current element scope.
>      *
>      * @return Returns namespace.
>      */
>     public OMNamespace declareNamespace(String uri, String prefix) {
>         if ("".equals(prefix))
>             prefix = OMSerializerUtil.getNextNSPrefix();
>         OMNamespaceImpl ns = new OMNamespaceImpl(uri, prefix);
>         return declareNamespace(ns);
>     }
> 
>     /**
>      * We use "" to store the default namespace of this element. As one can see user can not give ""
>      * as the prefix, when he declare a usual namespace.
>      *
>      * @param uri
>      */
>     public OMNamespace declareDefaultNamespace(String uri) {
>         if (uri == null || "".equals(uri)) {
>             return null;
>         }
>         OMNamespaceImpl namespace = new OMNamespaceImpl(uri, "");
> 
>         if (namespaces == null) {
>             this.namespaces = new HashMap(5);
>         }
>         namespaces.put("", namespace);
>         return namespace;
>     }
> 
>     public OMNamespace getDefaultNamespace() {
>         OMNamespace defaultNS;
>         if (namespaces != null && (defaultNS = (OMNamespace) namespaces.get("")) != null) {
>             return defaultNS;
>         }
>         if (parent instanceof OMElementImpl) {
>             return ((OMElementImpl) parent).getDefaultNamespace();
> 
>         }
>         return null;
>     }
> 
>     /**
>      * @return Returns namespace.
>      */
>     public OMNamespace declareNamespace(OMNamespace namespace) {
>         if (namespaces == null) {
>             this.namespaces = new HashMap(5);
>         }
>         String prefix = namespace.getPrefix();
>         if (prefix == null) {
>             prefix = OMSerializerUtil.getNextNSPrefix();
>             namespace = new OMNamespaceImpl(namespace.getName(), prefix);
>         }
>         namespaces.put(prefix, namespace);
>         return namespace;
>     }
> 
>     /**
>      * Finds a namespace with the given uri and prefix, in the scope of the document.
>      * Starts to find from the current element and goes up in the hiararchy until one is found.
>      * If none is found, returns null.
>      */
>     public OMNamespace findNamespace(String uri, String prefix) {
> 
>         // check in the current element
>         OMNamespace namespace = findDeclaredNamespace(uri, prefix);
>         if (namespace != null) {
>             return namespace;
>         }
> 
>         // go up to check with ancestors
>         if (parent != null) {
>             //For the OMDocumentImpl there won't be any explicit namespace
>             //declarations, so going up the parent chain till the document
>             //element should be enough.
>             if (parent instanceof OMElement) {
>                 namespace = ((OMElementImpl) parent).findNamespace(uri, prefix);
>             }
>         }
> 
>         return namespace;
>     }
> 
>     public OMNamespace findNamespaceURI(String prefix) {
>         OMNamespace ns =  this.namespaces==null?
>                 null:
>                 (OMNamespace)this.namespaces.get(prefix);
> 
>         if (ns == null && this.parent instanceof OMElement) {
>             // try with the parent
>             ns = ((OMElement) this.parent).findNamespaceURI(prefix);
>         }
>         return ns;
>     }
> 
>     /**
>      * Checks for the namespace <B>only</B> in the current Element.
>      * This is also used to retrieve the prefix of a known namespace URI.
>      */
>     private OMNamespace findDeclaredNamespace(String uri, String prefix) {
> 
> 
>         if (uri == null) {
>             return null;
>         }
> 
>         //If the prefix is available and uri is available and its the xml namespace
>         if (prefix != null && prefix.equals(OMConstants.XMLNS_PREFIX) && uri.equals(OMConstants.XMLNS_URI))
>         {
>             return new OMNamespaceImpl(uri, prefix);
>         }
> 
>         if (namespaces == null) {
>             return null;
>         }
> 
>         if (prefix == null || "".equals(prefix)) {
> 
>             OMNamespace defaultNamespace = this.getDefaultNamespace();
>             if (defaultNamespace != null && uri.equals(defaultNamespace.getName())) {
>                 return defaultNamespace;
>             }
>             Iterator namespaceListIterator = namespaces.values().iterator();
> 
>             String nsUri;
> 
>             while (namespaceListIterator.hasNext()) {
>                 OMNamespace omNamespace =
>                         (OMNamespace) namespaceListIterator.next();
>                 nsUri = omNamespace.getName();
>                 if (nsUri != null &&
>                         nsUri.equals(uri)) {
>                     return omNamespace;
>                 }
>             }
>         } else {
>             OMNamespace namespace = (OMNamespace) namespaces.get(prefix);
>             if (namespace != null && uri.equalsIgnoreCase(namespace.getName())) {
>                 return namespace;
>             }
>         }
>         return null;
>     }
> 
> 
>     /**
>      * Method getAllDeclaredNamespaces.
>      *
>      * @return Returns Iterator.
>      */
>     public Iterator getAllDeclaredNamespaces() {
>         if (namespaces == null) {
>             return EMPTY_ITERATOR;
>         }
>         return namespaces.values().iterator();
>     }
> 
>     /**
>      * Returns a List of OMAttributes.
>      *
>      * @return Returns iterator.
>      */
>     public Iterator getAllAttributes() {
>         if (attributes == null) {
>             return EMPTY_ITERATOR;
>         }
>         return attributes.values().iterator();
>     }
> 
>     /**
>      * Returns a named attribute if present.
>      *
>      * @param qname the qualified name to search for
>      * @return Returns an OMAttribute with the given name if found, or null
>      */
>     public OMAttribute getAttribute(QName qname) {
>         return attributes == null ? null : (OMAttribute) attributes.get(qname);
>     }
> 
>     /**
>      * Returns a named attribute's value, if present.
>      *
>      * @param qname the qualified name to search for
>      * @return Returns a String containing the attribute value, or null.
>      */
>     public String getAttributeValue(QName qname) {
>         OMAttribute attr = getAttribute(qname);
>         return (attr == null) ? null : attr.getAttributeValue();
>     }
> 
>     /**
>      * Inserts an attribute to this element. Implementor can decide as to insert this
>      * in the front or at the end of set of attributes.
>      *
>      * @return Returns attribute.
>      */
>     public OMAttribute addAttribute(OMAttribute attr) {
>         if (attributes == null) {
>             this.attributes = new HashMap(5);
>         }
>         OMNamespace namespace = attr.getNamespace();
>         if (namespace != null && this.findNamespace(namespace.getName(), namespace.getPrefix()) == null)
>         {
>             this.declareNamespace(namespace.getName(), namespace.getPrefix());
>         }
> 
>         attributes.put(attr.getQName(), attr);
>         return attr;
>     }
> 
>     /**
>      * Method removeAttribute.
>      */
>     public void removeAttribute(OMAttribute attr) {
>         if (attributes != null) {
>             attributes.remove(attr.getQName());
>         }
>     }
> 
>     /**
>      * Method addAttribute.
>      *
>      * @return Returns OMAttribute.
>      */
>     public OMAttribute addAttribute(String attributeName, String value,
>                                     OMNamespace ns) {
>         OMNamespace namespace;
>         if (ns != null) {
>             namespace = findNamespace(ns.getName(), ns.getPrefix());
>             if (namespace == null) {
>                 throw new OMException("Given OMNamespace(" + ns.getName() + " " +
>                         ns.getPrefix()
>                         + ") for "
>                         +
>                         "this attribute is not declared in the scope of this element. First declare the namespace"
>                         + " and then use it with the attribute");
>             }
>         }
>         return addAttribute(new OMAttributeImpl(attributeName, ns, value, this.factory));
>     }
> 
>     /**
>      * Method setBuilder.
>      */
>     public void setBuilder(OMXMLParserWrapper wrapper) {
>         this.builder = wrapper;
>     }
> 
>     /**
>      * Method getBuilder.
>      *
>      * @return Returns OMXMLParserWrapper.
>      */
>     public OMXMLParserWrapper getBuilder() {
>         return builder;
>     }
> 
>     /**
>      * Forces the parser to proceed, if parser has not yet finished with the XML input.
>      */
>     public void buildNext() {
>         builder.next();
>     }
> 
>     /**
>      * Method getFirstOMChild.
>      *
>      * @return Returns child.
>      */
>     public OMNode getFirstOMChild() {
>         while ((firstChild == null) && !done) {
>             buildNext();
>         }
>         return firstChild;
>     }
> 
>     /**
>      * Method setFirstChild.
>      */
>     public void setFirstChild(OMNode firstChild) {
>         if (firstChild != null) {
>             ((OMNodeEx) firstChild).setParent(this);
>         }
>         this.firstChild = firstChild;
>     }
> 
>     /**
>      * Removes this information item and its children, from the model completely.
>      *
>      * @throws OMException
>      */
>     public OMNode detach() throws OMException {
>         if (!done) {
>             build();
>         }
>         super.detach();
>         return this;
>     }
> 
>     /**
>      * Method isComplete.
>      *
>      * @return Returns boolean.
>      */
>     public boolean isComplete() {
>         return done;
>     }
> 
>     /**
>      * Gets the type of node, as this is the super class of all the nodes.
>      */
>     public int getType() {
>         return OMNode.ELEMENT_NODE;
>     }
> 
>     /**
>      * Method getXMLStreamReader.
>      *
>      * @see OMElement#getXMLStreamReader()
>      */
>     public XMLStreamReader getXMLStreamReader() {
>         return getXMLStreamReader(true);
>     }
> 
>     /**
>      * Method getXMLStreamReaderWithoutCaching.
>      *
>      * @see OMElement#getXMLStreamReaderWithoutCaching()
>      */
>     public XMLStreamReader getXMLStreamReaderWithoutCaching() {
>         return getXMLStreamReader(false);
>     }
> 
>     /**
>      * Method getXMLStreamReader.
>      *
>      * @return Returns reader.
>      */
>     private XMLStreamReader getXMLStreamReader(boolean cache) {
>         if ((builder == null) && !cache) {
>             throw new UnsupportedOperationException(
>                     "This element was not created in a manner to be switched");
>         }
>         if (builder != null && builder.isCompleted() && !cache) {
>             throw new UnsupportedOperationException(
>                     "The parser is already consumed!");
>         }
>         return new OMStAXWrapper(builder, this, cache);
>     }
> 
>     /**
>      * Sets the text of the given element.
>      * caution - This method will wipe out all the text elements (and hence any
>      * mixed content) before setting the text.
>      */
>     public void setText(String text) {
> 
>         OMNode child = this.getFirstOMChild();
>         while (child != null) {
>             if (child.getType() == OMNode.TEXT_NODE) {
>                 child.detach();
>             }
>             child = child.getNextOMSibling();
>         }
> 
>         OMAbstractFactory.getOMFactory().createOMText(this, text);
>     }
> 
>     /**
>      * Sets the text, as a QName, of the given element.
>      * caution - This method will wipe out all the text elements (and hence any
>      * mixed content) before setting the text.
>      */
>     public void setText(QName text) {
> 
>         OMNode child = this.getFirstOMChild();
>         while (child != null) {
>             if (child.getType() == OMNode.TEXT_NODE) {
>                 child.detach();
>             }
>             child = child.getNextOMSibling();
>         }
> 
>         OMAbstractFactory.getOMFactory().createOMText(this, text);
>     }
> 
>     /**
>      * Selects all the text children and concatinates them to a single string.
>      *
>      * @return Returns String.
>      */
>     public String getText() {
>         String childText = "";
>         OMNode child = this.getFirstOMChild();
>         OMText textNode;
> 
>         while (child != null) {
>             if (child.getType() == OMNode.TEXT_NODE) {
>                 textNode = (OMText) child;
>                 if (textNode.getText() != null &&
>                         !"".equals(textNode.getText())) {
>                     childText += textNode.getText();
>                 }
>             }
>             child = child.getNextOMSibling();
>         }
> 
>         return childText;
>     }
> 
>     public QName getTextAsQName() {
>         String childText = "";
>         OMNode child = this.getFirstOMChild();
>         OMText textNode;
> 
>         while (child != null) {
>             if (child.getType() == OMNode.TEXT_NODE) {
>                 textNode = (OMText) child;
>                 if (textNode.getText() != null &&
>                         !"".equals(textNode.getText())) {
>                     String namespaceURI = textNode.getTextAsQName().getNamespaceURI();
>                     if (namespaceURI != null && !"".equals(namespaceURI)) {
>                         return textNode.getTextAsQName();
>                     }
>                     childText += textNode.getText();
>                 }
>             }
>             child = child.getNextOMSibling();
>         }
> 
>         return new QName(childText);
>     }
> 
>     /**
>      * Returns the concatination string of TRIMMED values of all
>      * OMText  child nodes of this element.
>      * This is included purely to improve usability.
>      */
>     public String getTrimmedText() {
>         String childText = "";
>         OMNode child = this.getFirstOMChild();
>         OMText textNode;
> 
>         while (child != null) {
>             if (child.getType() == OMNode.TEXT_NODE) {
>                 textNode = (OMText) child;
>                 if (textNode.getText() != null &&
>                         !"".equals(textNode.getText().trim())) {
>                     childText += textNode.getText().trim();
>                 }
>             }
>             child = child.getNextOMSibling();
>         }
> 
>         return childText;
>     }
> 
>     /**
>      * Method internalSerialize.
>      *
>      * @throws XMLStreamException
>      */
>     public void internalSerialize(XMLStreamWriter writer) throws XMLStreamException {
>         internalSerialize(writer, true);
>     }
> 
> ///////////////////////////////////////////////////////////////////////////////////////////////
> //////////////////////////////////////////////////////////////////////////////////////////////
> 
>     protected void internalSerialize(XMLStreamWriter writer, boolean cache) throws XMLStreamException {
> 
>         if (cache) {
>             //in this case we don't care whether the elements are built or not
>             //we just call the serializeAndConsume methods
>             OMSerializerUtil.serializeStartpart(this, writer);
>             //serialize children
>             Iterator children = this.getChildren();
>             while (children.hasNext()) {
>                 ((OMNodeEx) children.next()).internalSerialize(writer);
>             }
>             OMSerializerUtil.serializeEndpart(writer);
> 
>         } else {
>             //Now the caching is supposed to be off. However caching been switched off
>             //has nothing to do if the element is already built!
>             if (this.done) {
>                 OMSerializerUtil.serializeStartpart(this, writer);
>                 OMNodeImpl child = (OMNodeImpl) firstChild;
>                 while (child != null && ((!(child instanceof OMElement)) || child.isComplete())) {
>                     child.internalSerializeAndConsume(writer);
>                     child = child.nextSibling;
>                 }
>                 if (child != null) {
>                     OMElement element = (OMElement) child;
>                     element.getBuilder().setCache(false);
>                     OMSerializerUtil.serializeByPullStream(element, writer, cache);
>                 }
>                 OMSerializerUtil.serializeEndpart(writer);
>             } else {
>               try
>               {
>               ByteArrayOutputStream buffer = new ByteArrayOutputStream();
>               
>               this.serialize(buffer);
>               buffer.close();
>               System.out.println(buffer.toString());
>               }catch(Exception e)
>               {
>                 System.out.println(e.getMessage());
>               }
> 
>               OMSerializerUtil.serializeByPullStream(this, writer, cache);
>             }
> 
> 
>         }
>     }
> 
> ////////////////////////////////////////////////////////////////////////////////////////////////
> ////////////////////////////////////////////////////////////////////////////////////////////////
> 
>     /**
>      * This method serializes and consumes without building the object structure in memory.
>      * Misuse of this method will cause loss of data. So it is advised to use
>      * populateYourSelf() method, before calling this method, if one wants to
>      * preserve data in the stream. This was requested during the second Axis2 summit.
>      *
>      * @throws XMLStreamException
>      */
>     public void internalSerializeAndConsume(XMLStreamWriter writer) throws XMLStreamException {
>         this.internalSerialize(writer, false);
>     }
> 
>     /**
>      * Gets first element.
>      *
>      * @return Returns element.
>      */
>     public OMElement getFirstElement() {
>         OMNode node = getFirstOMChild();
>         while (node != null) {
>             if (node.getType() == OMNode.ELEMENT_NODE) {
>                 return (OMElement) node;
>             } else {
>                 node = node.getNextOMSibling();
>             }
>         }
>         return null;
>     }
> 
>     /**
>      * Method getLocalName.
>      *
>      * @return Returns local name.
>      */
>     public String getLocalName() {
>         return localName;
>     }
> 
>     /**
>      * Method setLocalName.
>      */
>     public void setLocalName(String localName) {
>         this.localName = localName;
>     }
> 
>     /**
>      * Method getNamespace.
>      *
>      * @throws OMException
>      */
>     public OMNamespace getNamespace() throws OMException {
>         return ns != null ? ns : getDefaultNamespace();
>     }
> 
>     /**
>      * Method setNamespace.
>      */
>     public void setNamespace(OMNamespace namespace) {
>         OMNamespace nsObject = null;
>         if (namespace != null) {
>             nsObject = handleNamespace(namespace);
>         }
>         this.ns = nsObject;
>     }
> 
>     public void setNamespaceWithNoFindInCurrentScope(OMNamespace namespace) {
>         this.ns = namespace;
>     }
> 
>     /**
>      * Method getQName.
>      *
>      * @return Returns QName.
>      */
>     public QName getQName() {
>         QName qName;
>         if (ns != null) {
>             if (ns.getPrefix() != null) {
>                 qName = new QName(ns.getName(), localName, ns.getPrefix());
>             } else {
>                 qName = new QName(ns.getName(), localName);
>             }
>         } else {
>             qName = new QName(localName);
>         }
>         return qName;
>     }
> 
>     public String toStringWithConsume() throws XMLStreamException {
>         ByteArrayOutputStream baos = new ByteArrayOutputStream();
>         this.serializeAndConsume(baos);
>         return new String(baos.toByteArray());
>     }
> 
>     public String toString() {
>         ByteArrayOutputStream baos = new ByteArrayOutputStream();
>         try {
>             this.serialize(baos);
>         } catch (XMLStreamException e) {
>             throw new RuntimeException("Can not serialize OM Element " + this.getLocalName(), e);
>         }
>         return new String(baos.toByteArray());
>     }
> 
>     /**
>      * Method discard.
>      *
>      * @throws OMException
>      */
>     public void discard() throws OMException {
>         if (done) {
>             this.detach();
>         } else {
>             builder.discard(this);
>         }
>     }
> 
>     /**
>      * Converts a prefix:local qname string into a proper QName, evaluating it
>      * in the OMElement context. Unprefixed qnames resolve to the local namespace.
>      *
>      * @param qname prefixed qname string to resolve
>      * @return Returns null for any failure to extract a qname.
>      */
>     public QName resolveQName(String qname) {
>         ElementHelper helper = new ElementHelper(this);
>         return helper.resolveQName(qname);
>     }
> 
>     public OMElement cloneOMElement() {
>         OMElement clonedElement = new StAXOMBuilder(this.getXMLStreamReader(true)).getDocumentElement();
>         clonedElement.build();
>         return clonedElement;
>     }
> 
>     public void setLineNumber(int lineNumber) {
>         this.lineNumber = lineNumber;
>     }
> 
>     public int getLineNumber() {
>         return lineNumber;
>     }
> 
> }
> 
> 
> ------------------------------------------------------------------------
> 
> package org.apache.axis2.transport.http;
> 
> import org.apache.axiom.om.OMAttribute;
> import org.apache.axiom.om.OMElement;
> import org.apache.axiom.om.OMOutputFormat;
> import org.apache.axis2.AxisFault;
> import org.apache.axis2.Constants;
> import org.apache.axis2.context.MessageContext;
> import org.apache.axis2.context.OperationContext;
> import org.apache.axis2.description.Parameter;
> import org.apache.axis2.description.TransportOutDescription;
> import org.apache.axis2.i18n.Messages;
> import org.apache.axis2.util.Utils;
> import org.apache.commons.httpclient.Credentials;
> import org.apache.commons.httpclient.Header;
> import org.apache.commons.httpclient.HeaderElement;
> import org.apache.commons.httpclient.HostConfiguration;
> import org.apache.commons.httpclient.HttpClient;
> import org.apache.commons.httpclient.HttpMethod;
> import org.apache.commons.httpclient.HttpMethodBase;
> import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
> import org.apache.commons.httpclient.NTCredentials;
> import org.apache.commons.httpclient.NameValuePair;
> import org.apache.commons.httpclient.UsernamePasswordCredentials;
> import org.apache.commons.httpclient.auth.AuthScope;
> import org.apache.commons.httpclient.methods.RequestEntity;
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> 
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.io.OutputStream;
> import java.net.MalformedURLException;
> import java.net.URL;
> import java.util.Iterator;
> import java.util.zip.GZIPInputStream;
> 
> import javax.xml.namespace.QName;
> import javax.xml.stream.FactoryConfigurationError;
> import javax.xml.stream.XMLStreamException;
> 
> public abstract class AbstractHTTPSender {
>     protected static final String ANONYMOUS = "anonymous";
>     protected static final String PROXY_HOST_NAME = "proxy_host";
>     protected static final String PROXY_PORT = "proxy_port";
>     protected boolean chunked = false;
>     protected String httpVersion = HTTPConstants.HEADER_PROTOCOL_11;
> 	private static final Log log = LogFactory.getLog(AbstractHTTPSender.class);
>     int soTimeout = HTTPConstants.DEFAULT_SO_TIMEOUT;
> 
>     /**
>      * proxydiscription
>      */
>     protected TransportOutDescription proxyOutSetting = null;
>     protected OMOutputFormat format = new OMOutputFormat();
>     int connectionTimeout = HTTPConstants.DEFAULT_CONNECTION_TIMEOUT;
> 
>     public void setChunked(boolean chunked) {
>         this.chunked = chunked;
>     }
> 
>     public void setHttpVersion(String version) throws AxisFault {
>         if (version != null) {
>             if (HTTPConstants.HEADER_PROTOCOL_11.equals(version)) {
>                 this.httpVersion = HTTPConstants.HEADER_PROTOCOL_11;
>             } else
>             if (HTTPConstants.HEADER_PROTOCOL_10.equals(version)) {
>                 this.httpVersion = HTTPConstants.HEADER_PROTOCOL_10;
>                 // chunked is not possible with HTTP/1.0
>                 this.chunked = false;
>             } else {
>                 throw new AxisFault(
>                         "Parameter " + HTTPConstants.PROTOCOL_VERSION
>                                 + " Can have values only HTTP/1.0 or HTTP/1.1");
>             }
>         }
>     }
> 
>     /**
>      * Helper method to Proxy and NTLM authentication
>      *
>      * @param client
>      * @param proxySetting
>      * @param config
>      */
>     protected void configProxyAuthentication(HttpClient client,
>                                              TransportOutDescription proxySetting,
>                                              HostConfiguration config,
>                                              MessageContext msgCtx)
>             throws AxisFault {
>         Parameter proxyParam = proxySetting.getParameter(HTTPConstants.PROXY);
>         String usrName;
>         String domain;
>         String passwd;
>         Credentials proxyCred = null;
>         String proxyHostName = null;
>         int proxyPort = -1;
> 
>         if (proxyParam != null) {
>             String value = (String) proxyParam.getValue();
>             String split[] = value.split(":");
> 
>             // values being hard coded due best practise
>             usrName = split[0];
>             domain = split[1];
>             passwd = split[2];
> 
>             OMElement proxyParamElement = proxyParam.getParameterElement();
>             Iterator ite = proxyParamElement.getAllAttributes();
> 
>             while (ite.hasNext()) {
>                 OMAttribute att = (OMAttribute) ite.next();
> 
>                 if (att.getLocalName().equalsIgnoreCase(PROXY_HOST_NAME)) {
>                     proxyHostName = att.getAttributeValue();
>                 }
> 
>                 if (att.getLocalName().equalsIgnoreCase(PROXY_PORT)) {
>                     proxyPort = Integer.parseInt(att.getAttributeValue());
>                 }
>             }
> 
>             if (domain.equals("") || domain.equals(ANONYMOUS)) {
>                 if (usrName.equals(ANONYMOUS) && passwd.equals(ANONYMOUS)) {
>                     proxyCred = new UsernamePasswordCredentials("", "");
>                 } else {
>                     proxyCred = new UsernamePasswordCredentials(usrName,
>                             passwd);    // proxy
>                 }
>             } else {
>                 proxyCred = new NTCredentials(usrName, passwd, proxyHostName,
>                         domain);    // NTLM authentication with additionals prams
>             }
>         }
> 
>         HttpTransportProperties.ProxyProperties proxyProperties =
>                 (HttpTransportProperties.ProxyProperties) msgCtx
>                         .getProperty(HTTPConstants.PROXY);
> 
>         if (proxyProperties != null) {
>             if (proxyProperties.getProxyPort() != -1) {
>                 proxyPort = proxyProperties.getProxyPort();
>             }
> 
>             proxyHostName = proxyProperties.getProxyHostName();
>             if (proxyHostName == null
>                     || proxyHostName.length() == 0) {
>                 throw new AxisFault("Proxy Name is not valid");
>             }
> 
>             if (proxyProperties.getUserName().equals(ANONYMOUS)
>                     || proxyProperties.getPassWord().equals(ANONYMOUS)) {
>                 proxyCred = new UsernamePasswordCredentials("", "");
>             }
>             if (!proxyProperties.getUserName().equals(ANONYMOUS) &&
>                     !proxyProperties.getPassWord().equals(ANONYMOUS)) {
>                 proxyCred = new UsernamePasswordCredentials(
>                         proxyProperties.getUserName().trim(),
>                         proxyProperties
>                                 .getPassWord().trim()); // Basic Authentication
>             }
>             if (!proxyProperties.getDomain().equals(ANONYMOUS)) {
>                 if (!proxyProperties.getUserName().equals(ANONYMOUS) &&
>                         !proxyProperties.getPassWord().equals(ANONYMOUS) &&
>                         !proxyProperties.getDomain().equals(ANONYMOUS) &&
>                         proxyHostName != null) {
>                     proxyCred = new NTCredentials(
>                             proxyProperties.getUserName().trim(),
>                             proxyProperties.getPassWord().trim(), proxyHostName,
>                             proxyProperties
>                                     .getDomain().trim()); // NTLM Authentication
>                 }
>             }
>         }
> 
>         client.getState().setProxyCredentials(AuthScope.ANY, proxyCred);
>         config.setProxy(proxyHostName, proxyPort);
>     }
> 
>     /**
>      * Collect the HTTP header information and set them in the message context
>      *
>      * @param method
>      * @param msgContext
>      */
>     protected void obtainHTTPHeaderInformation(HttpMethodBase method,
>                                                MessageContext msgContext) {
>         Header header =
>                 method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
> 
>         if (header != null) {
>             HeaderElement[] headers = header.getElements();
> 
>             for (int i = 0; i < headers.length; i++) {
>                 NameValuePair charsetEnc =
>                         headers[i].getParameterByName(
>                                 HTTPConstants.CHAR_SET_ENCODING);
>                 OperationContext opContext = msgContext.getOperationContext();
>                 String name = headers[i].getName();
>                 if (name.equalsIgnoreCase(
>                         HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED)) {
>                     if (opContext != null) {
>                         opContext.setProperty(
>                                 HTTPConstants.MTOM_RECEIVED_CONTENT_TYPE,
>                                 header.getValue());
>                     }
>                 } else if (charsetEnc != null) {
>                     if (opContext != null) {
>                         opContext.setProperty(MessageContext.CHARACTER_SET_ENCODING,
>                                 charsetEnc.getValue());    // change to the value, which is text/xml or application/xml+soap
>                     }
>                 }
>             }
>         }
>         Header cookieHeader =
>                 method.getResponseHeader(HTTPConstants.HEADER_SET_COOKIE);
>         if (cookieHeader == null) {
>             cookieHeader =
>                     method.getResponseHeader(HTTPConstants.HEADER_SET_COOKIE2);
>         }
>         if (cookieHeader != null) {
>             msgContext.getServiceContext().setProperty(Constants.COOKIE_STRING,
>                     cookieHeader.getValue());
>         }
>     }
> 
>     protected void processResponse(HttpMethodBase httpMethod,
>                                    MessageContext msgContext)
>             throws IOException {
>         obtainHTTPHeaderInformation(httpMethod, msgContext);
> 
>         InputStream in = httpMethod.getResponseBodyAsStream();
> 
>         Header contentEncoding =
>             httpMethod.getResponseHeader(HTTPConstants.HEADER_CONTENT_ENCODING);
>         if (contentEncoding != null) {
>             if (contentEncoding.getValue().
>                     equalsIgnoreCase(HTTPConstants.COMPRESSION_GZIP)) {
>                 in =
>                     new GZIPInputStream(in);
>             } else {
>                 throw new AxisFault("HTTP :"
>                         + "unsupported content-encoding of '"
>                         + contentEncoding.getValue()
>                         + "' found");
>             }
>         }
> 
>         if (in == null) {
>             throw new AxisFault(
>                     Messages.getMessage("canNotBeNull", "InputStream"));
>         }
> 
>         if(msgContext.getOperationContext() != null) {
>             msgContext.getOperationContext()
>                     .setProperty(MessageContext.TRANSPORT_IN, in);
>         }
>     }
> 
>     public abstract void send(MessageContext msgContext, OMElement dataout,
>                               URL url,
>                               String soapActionString)
>             throws MalformedURLException, AxisFault, IOException;
> 
>     /**
>      * getting host configuration to support standard http/s, proxy and NTLM support
>      */
>     protected HostConfiguration getHostConfiguration(HttpClient client,
>                                                      MessageContext msgCtx,
>                                                      URL targetURL)
>             throws AxisFault {
>         boolean isHostProxy = isProxyListed(msgCtx);    // list the proxy
> 
>         boolean basicAuthenticationEnabled = serverBasicPreemtiveAuthentication(msgCtx); // server authentication
>         int port = targetURL.getPort();
> 
>         if (port == -1) {
>             port = 80;
>         }
> 
>         // to see the host is a proxy and in the proxy list - available in axis2.xml
>         HostConfiguration config = new HostConfiguration();
> 
>         if (!isHostProxy && !basicAuthenticationEnabled) {
>             config.setHost(targetURL.getHost(), port, targetURL.getProtocol());
>         }else if(basicAuthenticationEnabled){
>              // premtive authentication
>             this.configServerPreemtiveAuthenticaiton(client,msgCtx,config,targetURL);
>         } else {
> 
>             // proxy and NTLM configuration
>             this.configProxyAuthentication(client, proxyOutSetting, config,
>                     msgCtx);
>         }
> 
>         return config;
>     }
> 
>     private void configServerPreemtiveAuthenticaiton(HttpClient agent,
>                                                      MessageContext msgCtx,
>                                                      HostConfiguration config,
>                                                      URL targetURL) {
>         config.setHost(targetURL.getHost(), targetURL.getPort(),
>                        targetURL.getProtocol());
> 
>         agent.getParams().setAuthenticationPreemptive(true);
> 
>         HttpTransportProperties.BasicAuthentication basicAuthentication =
>                 (HttpTransportProperties.BasicAuthentication) msgCtx
>                         .getProperty(HTTPConstants.BASIC_AUTHENTICATION);
>         Credentials defaultCredentials = null;
>         if (basicAuthentication.getRealm() == null)
>         {
>            defaultCredentials = new UsernamePasswordCredentials(
>                 basicAuthentication.getUsername(),
>                 basicAuthentication.getPassword());
>         }else
>         {
>           defaultCredentials = new NTCredentials(
>             basicAuthentication.getUsername(),
>             basicAuthentication.getPassword(),
>             basicAuthentication.getHost(),
>             basicAuthentication.getRealm());
>             agent.getState().setCredentials(new AuthScope(
>               basicAuthentication.getHost(),
>               basicAuthentication.getPort(),
>               null), defaultCredentials);
>             
>             return;
>         }
>         if (basicAuthentication.getPort() == -1 ||
>             basicAuthentication.getHost() == null) {
>             agent.getState().setCredentials(AuthScope.ANY, defaultCredentials);
>         } else {
>             if (basicAuthentication.getRealm() == null) {
>                 agent.getState().setCredentials(new AuthScope(
>                         basicAuthentication.getHost(),
>                         basicAuthentication.getPort(),
>                         AuthScope.ANY_REALM), defaultCredentials);
> 
>             } else {
>                 agent.getState().setCredentials(new AuthScope(
>                         basicAuthentication.getHost(),
>                         basicAuthentication.getPort(),
>                         basicAuthentication.getRealm()), defaultCredentials);
>             }
>         }
> 
> 
>     }
> 
>     /**
>      * This is used to get the dynamically set time out values from the
>      * message context. If the values are not available or invalid then
>      * teh default values or the values set by teh configuration will be used
>      *
>      * @param msgContext
>      */
>     protected void getTimeoutValues(MessageContext msgContext) {
>         try {
> 
>             // If the SO_TIMEOUT of CONNECTION_TIMEOUT is set by dynamically the
>             // override the static config
>             Integer tempSoTimeoutProperty =
>                     (Integer) msgContext.getProperty(HTTPConstants.SO_TIMEOUT);
>             Integer tempConnTimeoutProperty =
>                     (Integer) msgContext
>                             .getProperty(HTTPConstants.CONNECTION_TIMEOUT);
> 
>             if (tempSoTimeoutProperty != null) {
>                 soTimeout = tempSoTimeoutProperty.intValue();
>             }
> 
>             if (tempConnTimeoutProperty != null) {
>                 connectionTimeout = tempConnTimeoutProperty.intValue();
>             }
>         } catch (NumberFormatException nfe) {
> 
>             // If there's a problem log it and use the default values
>             log.error("Invalid timeout value format: not a number", nfe);
>         }
>     }
> 
>     //Server Preemptive Authentication RUNTIME
> 
>     private boolean serverBasicPreemtiveAuthentication(MessageContext msgContext) {
> 
>         return msgContext.getProperty(HTTPConstants.BASIC_AUTHENTICATION) !=
>                null;
>     }
> 
>     private boolean isProxyListed(MessageContext msgCtx) throws AxisFault {
>         boolean returnValue = false;
>         Parameter par = null;
> 
>         proxyOutSetting = msgCtx.getConfigurationContext()
>                 .getAxisConfiguration().getTransportOut(
>                 new QName(Constants.TRANSPORT_HTTP));
> 
>         if (proxyOutSetting != null) {
>             par = proxyOutSetting.getParameter(HTTPConstants.PROXY);
>         }
> 
>         OMElement hostElement = null;
> 
>         if (par != null) {
>             hostElement = par.getParameterElement();
>         }
> 
>         if (hostElement != null) {
>             Iterator ite = hostElement.getAllAttributes();
> 
>             while (ite.hasNext()) {
>                 OMAttribute attribute = (OMAttribute) ite.next();
> 
>                 if (attribute.getLocalName().equalsIgnoreCase(PROXY_HOST_NAME))
>                 {
>                     returnValue = true;
>                 }
>             }
>         }
> 
>         HttpTransportProperties.ProxyProperties proxyProperties;
> 
>         if ((proxyProperties =
>                 (HttpTransportProperties.ProxyProperties) msgCtx.getProperty(
>                         HTTPConstants.PROXY)) != null) {
>             if (proxyProperties.getProxyHostName() != null) {
>                 returnValue = true;
>             }
>         }
> 
>         return returnValue;
>     }
> 
>     public void setFormat(OMOutputFormat format) {
>         this.format = format;
>     }
> 
>     public class AxisRequestEntity implements RequestEntity {
>         private boolean doingMTOM = false;
>         private byte[] bytes;
>         private String charSetEnc;
>         private boolean chunked;
>         private OMElement element;
>         private MessageContext msgCtxt;
>         private String soapActionString;
> 
>         public AxisRequestEntity(OMElement element, boolean chunked,
>                                  MessageContext msgCtxt,
>                                  String charSetEncoding,
>                                  String soapActionString) {
>             this.element = element;
>             this.chunked = chunked;
>             this.msgCtxt = msgCtxt;
>             this.doingMTOM = msgCtxt.isDoingMTOM();
>             this.charSetEnc = charSetEncoding;
>             this.soapActionString = soapActionString;
>         }
> 
>         private void handleOMOutput(OutputStream out, boolean doingMTOM)
>                 throws XMLStreamException {
>             format.setDoOptimize(doingMTOM);
>             element.serializeAndConsume(out, format);
>         }
> 
>         public byte[] writeBytes() throws AxisFault {
>             try {
>                 ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
> 
>                 if (!doingMTOM) {
>                     OMOutputFormat format2 = new OMOutputFormat();
> 
>                     format2.setCharSetEncoding(charSetEnc);
>                     element.serializeAndConsume(bytesOut, format2);
> 
>                     return bytesOut.toByteArray();
>                 } else {
>                     format.setCharSetEncoding(charSetEnc);
>                     format.setDoOptimize(true);
>                     element.serializeAndConsume(bytesOut, format);
> 
>                     return bytesOut.toByteArray();
>                 }
>             } catch (XMLStreamException e) {
>                 throw new AxisFault(e);
>             } catch (FactoryConfigurationError e) {
>                 throw new AxisFault(e);
>             }
>         }
> 
>         public void writeRequest(OutputStream out) throws IOException {
>             try {
>                 {
>                     if (chunked) {
>                         this.handleOMOutput(out, doingMTOM);
>                     } else {
>                         if (bytes == null) {
>                             bytes = writeBytes();
>                         }
> 
>                         out.write(bytes);
>                     }
>                 }
> 
>                 out.flush();
>             } catch (XMLStreamException e) {
>                 throw new AxisFault(e);
>             } catch (FactoryConfigurationError e) {
>                 throw new AxisFault(e);
>             } catch (IOException e) {
>                 throw new AxisFault(e);
>             }
>         }
> 
>         public long getContentLength() {
>             try {
>                 {
>                     if (chunked) {
>                         return -1;
>                     } else {
>                         if (bytes == null) {
>                             bytes = writeBytes();
>                         }
> 
>                         return bytes.length;
>                     }
>                 }
>             } catch (AxisFault e) {
>                 return -1;
>             }
>         }
> 
>         public String getContentType() {
>             String encoding = format.getCharSetEncoding();
>             String contentType = format.getContentType();
> 
>             if (encoding != null) {
>                 contentType += "; charset=" + encoding;
>             }
> 
>             // action header is not mandated in SOAP 1.2. So putting it, if available
>             if (!msgCtxt.isSOAP11() && (soapActionString != null)
>                     && !"".equals(soapActionString.trim())) {
>                 contentType =
>                         contentType + ";action=\"" + soapActionString + "\";";
>             }
> 
>             return contentType;
>         }
> 
>         public boolean isRepeatable() {
>             return true;
>         }
>     }
> 
>     protected HttpClient getHttpClient(MessageContext msgContext) {
>         HttpClient httpClient = null;
>         Boolean reuse = (Boolean) msgContext.getOptions().getProperty(HTTPConstants.REUSE_HTTP_CLIENT);
>         if(reuse != null && reuse.booleanValue()) {
>             httpClient = (HttpClient) msgContext.getConfigurationContext().getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
>             if(httpClient == null){
>                 MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
>                 httpClient = new HttpClient(connectionManager);
>                 msgContext.getConfigurationContext().setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
>             }
>         } else {
>             httpClient = new HttpClient();
>         }
> 
>         // Get the timeout values set in the runtime
>         getTimeoutValues(msgContext);
> 
>         // SO_TIMEOUT -- timeout for blocking reads
>         httpClient.getHttpConnectionManager().getParams().setSoTimeout(soTimeout);
> 
>         // timeout for initial connection
>         httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(connectionTimeout);
>         return httpClient;
>     }
> 
>     protected void executeMethod(HttpClient httpClient, MessageContext msgContext, URL url, HttpMethod method) throws IOException {
>         HostConfiguration config = this.getHostConfiguration(httpClient, msgContext, url);
>         msgContext.setProperty(HTTPConstants.HTTP_METHOD, method);
> 
>         // add compression headers if needed
>         if (Utils.isExplicitlyTrue(msgContext, HTTPConstants.MC_ACCEPT_GZIP)) {
>             method.addRequestHeader(HTTPConstants.HEADER_ACCEPT_ENCODING,
>                     HTTPConstants.COMPRESSION_GZIP);
>         }
>         if (Utils.isExplicitlyTrue(msgContext, HTTPConstants.MC_GZIP_REQUEST)) {
>             method.addRequestHeader(HTTPConstants.HEADER_CONTENT_ENCODING,
>                     HTTPConstants.COMPRESSION_GZIP);
>         }
> 
>         httpClient.executeMethod(config, method);
>     }
> }
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFEf+YkYmklbLuW6wYRAnJmAJ9MZ574y0VO9M/cL4/JjtVs45C5VwCfW8Hl
DZz6y+SKKxERlE0vqdkxQic=
=N/OA
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org