[ http://issues.apache.org/jira/browse/AXIS2-1143?page=all ]
Davanum Srinivas resolved AXIS2-1143. ------------------------------------- Resolution: Fixed marking as fixed. > Basic Authentication with client stub > ------------------------------------- > > Key: AXIS2-1143 > URL: http://issues.apache.org/jira/browse/AXIS2-1143 > Project: Apache Axis 2.0 (Axis2) > Issue Type: Bug > Affects Versions: 1.0 > Environment: Windows XP > Reporter: christopher dang > Attachments: ws.java, wsdl1.wsdl > > > Used WSDL2Java to generate client stub from the following wsdl: > <?xml version="1.0" encoding="UTF-8"?> > <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" > xmlns:reqns="http://www.exampleApp.TrafficAccident.Request.com" > xmlns:resns="http://www.exampleApp.TrafficAccident.Response.com" > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" > xmlns:tns="http://www.exampleApp.TrafficAccident.com" > targetNamespace="http://www.exampleApp.TrafficAccident.com"> > <types> > <xsd:schema xmlns:tns="http://www.exampleApp.TrafficAccident.Request.com" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > attributeFormDefault="qualified" > elementFormDefault="qualified" > targetNamespace="http://www.exampleApp.TrafficAccident.Request.com" > xmlns:reqns="http://www.exampleApp.TrafficAccident.Request.com"> > <xsd:element name="TrafficAccidentRequest" nillable="false"> > <xsd:complexType mixed="false"> > <xsd:sequence> > <xsd:element name="ACCKEY" nillable="false"> > <xsd:simpleType> > <xsd:restriction base="xsd:string"> > <xsd:maxLength value="20"/> > <xsd:whiteSpace value="preserve"/> > </xsd:restriction> > </xsd:simpleType> > </xsd:element> > <xsd:element name="AGENCY_ID" nillable="false"> > <xsd:simpleType> > <xsd:restriction base="xsd:string"> > <xsd:maxLength value="20"/> > <xsd:whiteSpace value="preserve"/> > </xsd:restriction> > </xsd:simpleType> > </xsd:element> > </xsd:sequence> > </xsd:complexType> > </xsd:element> > </xsd:schema> > <xsd:schema xmlns:tns="http://www.exampleApp.TrafficAccident.Response.com" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > attributeFormDefault="qualified" > elementFormDefault="qualified" > targetNamespace="http://www.exampleApp.TrafficAccident.Response.com"> > <xsd:element name="TrafficAccidentResponse" nillable="false"> > <xsd:complexType mixed="false"> > <xsd:sequence> > <xsd:element name="ACCKEY" nillable="false"> > <xsd:simpleType> > <xsd:restriction base="xsd:string"> > <xsd:maxLength value="20"/> > <xsd:whiteSpace value="preserve"/> > </xsd:restriction> > </xsd:simpleType> > </xsd:element> > <xsd:element name="VEHKEY" nillable="false"> > <xsd:simpleType> > <xsd:restriction base="xsd:string"> > <xsd:maxLength value="20"/> > <xsd:whiteSpace value="preserve"/> > </xsd:restriction> > </xsd:simpleType> > </xsd:element> > </xsd:sequence> > </xsd:complexType> > </xsd:element> > </xsd:schema> > </types> > <message name="TrafficAccidentResponse"> > <part element="resns:TrafficAccidentResponse" name="ResponseAccident"/> > </message> > <message name="TrafficAccidentRequest"> > <part element="reqns:TrafficAccidentRequest" name="RequestAccident"/> > </message> > <portType name="TrafficAccidentPort"> > <operation name="TrafficAccident"> > <input message="tns:TrafficAccidentRequest" name="TrAccRequest"/> > <output message="tns:TrafficAccidentResponse" name="TrAccResponse"/> > </operation> > </portType> > <binding name="TrafficAccidentSoapBinding" type="tns:TrafficAccidentPort"> > <soap:binding style="document" > transport="http://schemas.xmlsoap.org/soap/http"/> > <operation name="TrafficAccident"> > <soap:operation soapAction="" style="document"/> > <input name="TrAccRequest"> > <soap:body parts="RequestAccident" use="literal"/> > </input> > <output name="TrAccResponse"> > <soap:body parts="ResponseAccident" use="literal"/> > </output> > </operation> > </binding> > <service name="TrafficAccidentService"> > <port binding="tns:TrafficAccidentSoapBinding" name="TrafficAccidentPort"> > <soap:address > location="http://citsf.state.co.us:25007/cics/cwba/cwshttpx"/> > </port> > </service> > </definitions> > Tried to access the web service with the following code: > public class ws { > public static void main( String[] args ) { > try { > > org.apache.axis2.transport.http.HttpTransportProperties.BasicAuthentication > ba = > new > org.apache.axis2.transport.http.HttpTransportProperties.BasicAuthentication(); > ba.setPassword( "password" ); > ba.setUsername( "username" ); > com.trafficaccident.exampleapp.www.TrafficAccidentServiceStub stub = > new > com.trafficaccident.exampleapp.www.TrafficAccidentServiceStub(); > org.apache.axis2.client.Options op = > stub._getServiceClient().getOptions(); > op.setProperty( > org.apache.axis2.transport.http.HTTPConstants.BASIC_AUTHENTICATION, > ba ); > op.setProperty( > org.apache.axis2.Constants.Configuration.TRANSPORT_URL > ,"http://citsf.state.co.us:25007/cics/cwba/cwshttpx"); > > com.request.trafficaccident.exampleapp.www.TrafficAccidentRequestDocument doc > = > > com.request.trafficaccident.exampleapp.www.TrafficAccidentRequestDocument.Factory.newInstance(); > > com.request.trafficaccident.exampleapp.www.TrafficAccidentRequestDocument.TrafficAccidentRequest > req = doc.addNewTrafficAccidentRequest(); > req.setACCKEY( "ACCKEY" ); > req.setAGENCYID( "AGENCYID" ); > stub._getServiceClient().getAxisService().addMessageReceiver( "test", > new org.apache.axis2.engine.MessageReceiver() { > public void receive(org.apache.axis2.context.MessageContext > mctx ) { > System.out.println( mctx ); > } > } ); > doc.setTrafficAccidentRequest( req ); > > com.response.trafficaccident.exampleapp.www.TrafficAccidentResponseDocument > res = stub.TrafficAccident( doc ); > System.out.println( res ); > } catch( Exception e ) { > e.printStackTrace(); > } > } > } > Received this error: > 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!; 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! > at > org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:231) > at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:643) > at > org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:355) > at > org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:285) > at > com.trafficaccident.exampleapp.www.TrafficAccidentServiceStub.TrafficAccident(TrafficAccidentServiceStub.java:139) > at ws.main(ws.java:30) > Caused by: 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! > at > org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:335) > at > org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:210) > ... 5 more > Caused by: 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! > at > org.apache.axis2.transport.http.SOAPOverHTTPSender$AxisSOAPRequestEntity.writeRequest(SOAPOverHTTPSender.java:244) > at > org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:495) > at > org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1973) > at > org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993) > at > org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397) > at > org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170) > at > org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396) > at > org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346) > at > org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:676) > at > org.apache.axis2.transport.http.SOAPOverHTTPSender.send(SOAPOverHTTPSender.java:113) > at > org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:329) > ... 6 more > Caused by: javax.xml.stream.XMLStreamException: problem accessing the parser. > Parser already accessed! > at > org.apache.axiom.om.impl.llom.OMStAXWrapper.next(OMStAXWrapper.java:897) > at > org.apache.axiom.om.impl.serialize.StreamingOMSerializer.serializeNode(StreamingOMSerializer.java:74) > at > org.apache.axiom.om.impl.serialize.StreamingOMSerializer.serialize(StreamingOMSerializer.java:59) > at > org.apache.axiom.om.impl.util.OMSerializerUtil.serializeByPullStream(OMSerializerUtil.java:469) > at > org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:780) > at > org.apache.axiom.om.impl.llom.OMElementImpl.internalSerializeAndConsume(OMElementImpl.java:803) > at > org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:774) > at > org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SOAPEnvelopeImpl.java:177) > at > org.apache.axiom.om.impl.llom.OMElementImpl.internalSerializeAndConsume(OMElementImpl.java:803) > at > org.apache.axiom.om.impl.llom.OMNodeImpl.serializeAndConsume(OMNodeImpl.java:392) > at > org.apache.axis2.transport.http.SOAPOverHTTPSender$AxisSOAPRequestEntity.handleOMOutput(SOAPOverHTTPSender.java:188) > at > org.apache.axis2.transport.http.SOAPOverHTTPSender$AxisSOAPRequestEntity.writeRequest(SOAPOverHTTPSender.java:230) > ... 16 more -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]