Deploying SOAP 1.2 based webservice in Glassfish
The following blog shows how to create and deploy a SOAP 1.2 based
webservice in Glassfish v2 using Netbeans6.0
Download and install Netbeans 6.0 from
href="http://download.netbeans.org/netbeans/6.0/final/">here.
Click on File->New Project
Choose Web ->WebApplication

Next provide the name of the Web application
choose the Java EE version as Java EE 5

Click on Finish
Next in the Projects tab you will see EchoTest
Right Click on EchoTest and create New WebService

Click Finish
Next we add operations to the service
Click the source tab in the center pane you will see the Echo.java
source code
Add the following operation to the source code (This can be done by
right clicking Webservices->EchoService->AddOperation)
* Web service operation
@WebMethod(operationName = "echoString"
public String echoString( @WebParam(name = "parameter") String parameter) {
return "hello" + parameter;
}
Add the following annotation
@javax.xml.ws.BindingType(value="http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/"
)The above is important because the default binding supported by
JAXWS 2.0 is SOAP 1.1 over HTTP.
This is how the source code looks

Right Click on EchoTest project
Do Clean and Build
Do Undeploy and Deploy
You will see the service is deployed at
http://localhost:8080/EchoTest/EchoService?wsdl
Next step build a client
File -> New Project -> Web Application (Same as fig 1)
Name the project as EchoClient

Click Finish
Right click on EchoClientTest and click New Webservice Client
Specify the wsdllocation as shown

Click Finish
Next expand
EchoClientTest->WebServiceReferences->EchoService->EchoService->EchoPort->echoString

Drag echoString and drop after line
This is how the jsp will look

Next Right click and call Run the EchoClientTest
This is what you see when you call
http://localhost:8080/EchoClientTest/
Hello World!
Result = hello John Doe
Advanced Tip
If you want to see the soap messages add the following line in
GF/domains/domain1/confiig/domain.xml in java-config element
<jvm-options>-Dcom.sun.xml.ws.assembler.server=true</jvm-options>
Then stop the GF server and restart it
Next go to http://localhost:8080/EchoClientTest/
You can see the following messages in GF/domains/domain1/logs/server.log
Request
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">
<S:Body>
<ns2:echoString xmlns:ns2="http://test/">
<parameter> John
Doe</parameter>
</ns2:echoString>
</S:Body>
</S:Envelope>
Response
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">
<S:Body>
<ns2:echoStringResponse xmlns:ns2="http://test/">
<return>hello John
Doe</return>
</ns2:echoStringResponse>
</S:Body>
</S:Envelope>
]
- Login or register to post comments
- Printer-friendly version
- bhaktimehta's blog
- 7924 reads






Comments
Nice tutorial, Bhakti, but where did you get the "John Doe" ...
by manfred82 - 2009-11-10 07:49
Nice tutorial, Bhakti, but where did you get the "John Doe" echo String from? Though it was not specified as a parameter in the echo web service, it suddenly appears in the source code when the echo string is dropped into the client web service JSP page.Regards,
Karl, ASX data
by freddiefishcake - 2009-01-19 13:04
(the xml was removed from previous posting .. so here is is without the angle brackets: from S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" to S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope"Thank you! This statement
by vavilon7 - 2010-01-09 15:25
Thank you! This statement helped me. I have long tried to solve this problem.by freddiefishcake - 2009-01-19 13:02
Hi Bhakti, a) I started from NetBeans 6.5 and found that it's default is still SOAP 1.1 rather than 1.2 - are there still valid reasons to use SOAP 1.1 for new projects? b) your method works perfectly; however the resulting SOAP message looks very similar to the original message, the only difference appears to be the namespace which changes from to The rest of the message seems to be unchanged - is this what you would expect? c) the W3C overview of SOAP 1.2 (http://www.w3.org/2003/06/soap11-soap12.html) suggests that 1.2 enables benefits including "compression, optimization, and other performance gains" .. Netbeans / GlassFish QoS seems to suggest that e.g. FastInfoset is automagically negotiated, but all I see in e.g. wireShark is the same old xml streams - are there any good posts to show how to enable e.g. compression when uploading large payloads (e.g. jpg) from a client to a webService?by ds122787 - 2008-06-11 15:53
I tried this annotation @javax.xml.ws.BindingType(value="http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/" ) with a stateless session bean exposed as WS and that didn't work. Is it known Metro limitation? -Deepaby ialam - 2008-01-31 20:23
Hi Bhakti. I'm a new support technician to a large software company where i'm seeing TD analysis is very important for our web application. We utilize Weblogic 9.2 and was hoping you could give me some pointers on what I should be looking out for in a TDA report. I see many locking monitors, but what piece of these locks are the root causes? Any help is much appreciated. Thanks. Iftekharby 9chintan - 2008-02-21 21:41
Hi Bhakti, I am a newbie to web service and possibly this might sound odd but I rearranged the property to the very end of list and it works!!! Thanks for your help. I am using the glassfish bundled with Netbeans6.0 Sorry for my bad. Thanks Chintanby bhaktimehta - 2008-02-21 13:34
Hi chintan That is the only property which is needed. Which version of GF are you using. You can also see if http://localhost:8080/EchoTest/EchoService?Tester is working and try to see the soap messages there However that will work only if you are using a GF v2.1 build after feb 8 because I fixed issue 4122 https://glassfish.dev.java.net/issues/show_bug.cgi?id=4122 Regards, Bhaktiby 9chintan - 2008-02-21 13:05
Hi Bhakti, I followed your advanced tip. Still I am not able to see the SOAP Message in my server log. Anything I need to be aware of. Thanks for your help. Regards, Chintan.