This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Web Services and the fly likes Exception using Web Client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Exception using Web Client" Watch "Exception using Web Client" New topic
Author

Exception using Web Client

satya devarapalli
Greenhorn

Joined: Jan 28, 2009
Posts: 8
Hi,

Trying to consume some services through wsdl file given by the customer.
Its RPC-encoded SOAP protocol.
Platform:
Java 1.5
Axis1.4
Tomcat 4.1.39
Eclipse 3.4.1 on Mac 10.5
Tryin to execute
call = (Call) (new Service()).createCall();
call.setTargetEndpointAddress(new java.net.URL(epr));//epr is the wsdl url
call.setOperationName(new QName(target, opName));//target is the TargetNameSpace
call.addParameter("user_no", XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter("building", XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter("unit", XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter("resident", XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter("ManagementCompany", XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType(XMLType.SOAP_STRING);
String ts="";
ts = (String) call.invoke(new Object[]{"11465", "", "", "", "jenark"});
****It returns successful when the parameters are passed as a http request from the browser. Any help in this is appreciated.
The exception ....
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXException: Bad envelope tag: definitions
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: Bad envelope tag: definitions
at org.apache.axis.message.EnvelopeBuilder.startElement(EnvelopeBuilder.java:71)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at accountNS.AccountNSPortProxy.currentBalance(AccountNSPortProxy.java:146)
at org.apache.jsp.Result_jsp._jspService(Result_jsp.java:123)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:720)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:162)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:720)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:199)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:145)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:139)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2460)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:119)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:157)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:613)

Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
Welcome to CodeRanch

satya dsp wrote:****It returns successful when the parameters are passed as a http request from the browser. Any help in this is appreciated.


No really relevant as browsers don't use SOAP.

How to Get Help with SOAP web services

However this looks similar to this problem.

satya dsp wrote: faultString: org.xml.sax.SAXException: Bad envelope tag: definitions


"definitions" is an element name used inside a WSDL file. The WSDL file contains the endpoint reference - it is not the web service end point address.

Look for something like

The location attribute contains the endpoint reference.


so epr should not contain the WSDL address - but instead the endpoint reference.


"Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
"satya dsp",

Please check your private messages regarding an important administrative matter.
satya devarapalli
Greenhorn

Joined: Jan 28, 2009
Posts: 8
Thankyou for the reply.


I tried using the end-point reference that is in the location object to set the TargetEndpointAddress but it still gives the same exception.

I have to tell you that the actual WSDL from the client url has some validation errors. So I copied into my local machine made necessary changes(Typo, Adding a missing operation in the binding element). Then using this I generated the stubs in eclipse, axis1.4. Am not sure what role it plays by invoking an operation call using this stub generated from local wsdl.
Using the generated code, it raises the same exception I mentioned before while invoking the call.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
satya devarapalli wrote:I have to tell you that the actual WSDL from the client url has some validation errors.


Given your experience so far I wouldn't necessarily trust that WSDL. If at all possible find a consumer application that already works with that web service and use tcpmon (or something like it) to capture the actual SOAP messages that are exchanged. That will probably give you a better base from which to proceed.

How to Get Help with SOAP web services
satya devarapalli
Greenhorn

Joined: Jan 28, 2009
Posts: 8
Unfortunately I do not have any application that uses the web service. I have to ask the customer. I tried tcpmon, but the request, response were in html(not sure whether I am doin the rite way). Please suggest me with any open published working wsdl files on the internet so that I can look at the tcpmon request..responses.

Meanwhile, looking at the exception log, I explored the axis source code and found something interesting..

http://svn.apache.org/viewvc/webservices/axis/trunk/java/src/org/apache/axis/message/EnvelopeBuilder.java?view=markup

{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: Bad envelope tag: definitions
at org.apache.axis.message.EnvelopeBuilder.startElement(EnvelopeBuilder.java:71)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)

In the EnvelopeBuilder.startElement method it says,

Its looking for ENVELOPE tag but encounters a DEFINITIONS tag and raises exception. I know that its trying to build a SOAP message but not sure what is going on. Am I in the rite track?

Thanks for your time.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
satya devarapalli wrote:Please suggest me with any open published working wsdl files on the internet so that I can look at the tcpmon request..responses.


If you use the JDK 1.6 on some computer you can run this entire example (StockQuote) for practice.

Its looking for ENVELOPE tag but encounters a DEFINITIONS tag and raises exception. I know that its trying to build a SOAP message but not sure what is going on. Am I in the rite track?


Actually, it's trying to parse a SOAP envelope - but it's got a WSDL file ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception using Web Client
 
Similar Threads
Error when installing on server
j2me servlet communication
Getting "reflect.InvocationTargetException:" in Unix and not in Windows
org.apache.jasper.jasperexception index 0 size 0
catching NoClassDefFoundError