need help with web service client

B

balajio

Hi Everybody,

I am having a problem with a web service client calling a web service
residing on a JBoss 4.0.1 SP1 application server.

The web service has single method, sayHelloWorld. It does not take any
parameters and returns "Hello World !!". The client and the application
server reside on the same PC running Windows XP Pro(SP2).

Here are the request and response messages I see in tcpmon:

============================REQUEST============================
GET /HelloWorldWS/HelloWorldWS HTTP/1.1
User-Agent: Java/1.4.2
Host: localhost
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
========================END OF REQUEST=========================

============================RESPONSE===========================
HTTP/1.1 200 OK
X-Powered-By: Servlet 2.4; Tomcat-5.0.28/JBoss-4.0.1sp1 (build:
CVSTag=JBoss_4_0_1_SP1 date=200502160314)
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 498
Date: Sun, 03 Apr 2005 02:55:36 GMT
Server: Apache-Coyote/1.1

<head>
<meta http-equiv='Content-Type content='text/html; charset=iso-8859-1'>
<title>JBossWS</title>
<link rel='stylesheet' href='/ws4ee/styles.css'>
</head>
<h2>And now... Some Services</h2>
<ul>
<li>HelloWorldWS.war#HelloWorldIF<a
href='http://rainbow:8080/HelloWorldWS/HelloWorldWS?wsdl'>&nbsp;<i>(wsdl)</i></a></li><ul><li>sayHelloWorld</li></ul>
<li>Version<a
href='http://localhost/HelloWorldWS/services/Version?wsdl'>&nbsp;<i>(wsdl)</i></a></li><ul><li>getVersion</li></ul>
</ul>
========================END OF RESPONSE========================

The error message I get in the exception on the client side is:
===========================ERROR============================
Error processing WSDL document:
org.xml.sax.SAXException: Fatal Error:
URI=http://localhost:7070/HelloWorldWS/HelloWorldWS Line=2: Whitespace
required before attributes.
========================END OF ERROR========================

If you see in the response, the http-equiv attribute value does not
have a closing quote and the SAX parser is throwing an exception, from
what I understand and see.

Is there any configuration required either on the server side or the
client side ? I did not do any configuration and just followed the
documentation for JBoss 4.0.1 app server.

Has anybody seen this error before ? Or, does anybody have any idea why
the malformed repsonse message is generated ?

Appreciate your thoughts/ideas to resolve this error and thanks in
advance.
 
C

Chris Smith

balajio said:
I am having a problem with a web service client calling a web service
residing on a JBoss 4.0.1 SP1 application server.

The web service has single method, sayHelloWorld. It does not take any
parameters and returns "Hello World !!". The client and the application
server reside on the same PC running Windows XP Pro(SP2).

Here are the request and response messages I see in tcpmon:

Here's your first problem. The URL you're using is wrong. Based on the
messages from the client, it's expecting a WSDL document. Your request
is reaching an HTML document that's intended to give a convenient
introduction of the service. You should append the query string ?wsdl
to the end of the URL.

As for why the HTML is not parsing correctly, it's mainly because it's
HTML and HTML user agents are generally more forgiving that XML user
agents are allowed to be. That's still an odd mistake to make, but you
shouldn't be parsing that response as XML anyway.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
F

Frank Langelage

Hi Chris,

Thank you for the response. The client app is not really interested in
the WSDL. This is done by SOAP on the client side. Also, I am not
parsing the XML or HTML and is again done by SOAP.

Here is the code in the client. Hope this gives a better idea of what I
am tring to do.
=================CLIENT CODE=================
============END OF CLIENT CODE==============

Your application or better the classes and methods used there are
intereseted in the wsdl file.
So you should take the hint you got already and append "?wsdl" to urlstr.
The location of the soap service is within the wsdl file.
 
B

balajio

Frank said:
Your application or better the classes and methods used there are
intereseted in the wsdl file.
So you should take the hint you got already and append "?wsdl" to urlstr.
The location of the soap service is within the wsdl file.

Hi Chris and Frank,

Thank you for your responses. I got the client application working on
my PC and appending the string "?wsdl" helped make it work though I ran
into another problem for which I found a work around.

In the web.xml file, there is a "servlet-class" tag whose value should
be the name of the class(like "myPkg.MyClass") implementing the methods
for the web service. On JBoss startup, the class name in servlet-class
tag is replaced with another class(org.apache.....) and when I try to
invoke the method, I get the NoSuchMethodException. So, I copied the
web.xml over the existing one and I invoke the method which works fine.

Why does JBoss replace my class name with a different class name on
startup ? Anybody has any idea or seen this happening ? Is this a bug
in JBoss or is it caused by not configuring something(?) ?

Thanks
 
F

Frank Langelage

Hi Chris and Frank,
Thank you for your responses. I got the client application working on
my PC and appending the string "?wsdl" helped make it work though I ran
into another problem for which I found a work around.

In the web.xml file, there is a "servlet-class" tag whose value should
be the name of the class(like "myPkg.MyClass") implementing the methods
for the web service. On JBoss startup, the class name in servlet-class
tag is replaced with another class(org.apache.....) and when I try to
invoke the method, I get the NoSuchMethodException. So, I copied the
web.xml over the existing one and I invoke the method which works fine.

Why does JBoss replace my class name with a different class name on
startup ? Anybody has any idea or seen this happening ? Is this a bug
in JBoss or is it caused by not configuring something(?) ?

Thanks

The modification of web.xml is the normal behaviour of jboss.
The servlet-class you provide is no servlet class. It does not implement
javax.servlet.Servlet.
So jboss puts in a real servlet-class which gets the class you provided
as init-parameter.
The servlet-class name is
org.jboss.webservice.server.ServiceEndpointServletJSE or
org.jboss.webservice.server.ServiceEndpointServletEJB.
This class is then invoked by the webserver (tomcat) and calls your
webservice class.

I don't know now, why this doesn't work for you.
I wonder, that replacing web.xml with web.xml.org works.

Regards,
Frank
 
B

balajio

Frank said:
The modification of web.xml is the normal behaviour of jboss.
The servlet-class you provide is no servlet class. It does not implement
javax.servlet.Servlet.
So jboss puts in a real servlet-class which gets the class you provided
as init-parameter.
The servlet-class name is
org.jboss.webservice.server.ServiceEndpointServletJSE or
org.jboss.webservice.server.ServiceEndpointServletEJB.
This class is then invoked by the webserver (tomcat) and calls your
webservice class.

I don't know now, why this doesn't work for you.
I wonder, that replacing web.xml with web.xml.org works.

Regards,
Frank


Hi Frank,

Makes sense from what you described. I was worried I missed some
configuration step(s) and was causing this behaviour. Now that I found
a work around to the problem I was having with web services, I moved
onto other topics of J2EE and the going is good so far.

Thank you for the explanation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top