JulioQc
JulioQc

Reputation: 307

Netbeans debug web service and web client

I'm using Netbeans to create both a web client and a web service which are deployed on Glashfish (in debug mode).

I put some breakpoints in the web service but when I launch the web client (in debug) and trigger the call to the web service's methods, it never stops at the breakpoints I set.

I do get a proper SOAP response so I know the code of the web service is executed. Is there a way to debug the web service when launching the web client?

For now I use a Main class in the web service to simulate the client or for methods not using complex types, I can use 'Test web service' from Netbeans.

Upvotes: 0

Views: 1595

Answers (1)

Namphibian
Namphibian

Reputation: 12211

Some thoughts:

  • Get SOAP-UI for testing. Its much better than any client you can generate. You can also use it between services.

Once you have SOAP-UI installed launch glassfish in debug mode. Deploy your web-services. Create a new SOAP-UI project and point it to the WSDL file of the web services you deployed.

WARNING: SOAP-UI aint pretty but it is pretty good.

Once you have imported the WSDL open the SOAP project nodes till you see the operations of the web service.

You should see something like this:

SOAP UI

Expand the operations and fill in the missing pieces of the request. Missing values will be indicated by a ? in the XML request, they should look something like this in the initial request:

   <ecol:accountTotalDue>
           <!--Optional:-->
           <acc:AccountKeyInfo>
              <!--Optional:-->
              <acc:Client_Ref>?</acc:Client_Ref>
              <!--Optional:-->
              <acc:Debt_ID>?</acc:Debt_ID>
           </acc:AccountKeyInfo>
           <!--Optional:-->
           <acc:Total_Due>?</acc:Total_Due>
        </ecol:accountTotalDue>

You can hard code them like this:

    <ecol:accountTotalDue>
           <!--Optional:-->
           <acc:AccountKeyInfo>
              <!--Optional:-->
              <acc:Client_Ref>12834756183754</acc:Client_Ref>
              <!--Optional:-->
              <acc:Debt_ID>?</acc:Debt_ID>
           </acc:AccountKeyInfo>
           <!--Optional:-->
           <acc:Total_Due>10000000.00</acc:Total_Due>
        </ecol:accountTotalDue>

Note you can script them too for example my web services requires a GUUID and message date time in a special header sections so I do the following:

<irix:MsgReqHdr>
         <irix:MsgGUID>${=java.util.UUID.randomUUID()}</irix:MsgGUID>
           <!--Optional:-->
           <irix:MsgDateTime>${=javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(GregorianCalendar.getInstance())}</irix:MsgDateTime>
</irix:MsgReqHdr>

You could set up different requests to test different scenarios. It is really a must HAVE if you are doing serious Web services development. It also does REST.

This generally works a lot better for me than anything else. I have done this with JBoss, Glassfish, Karaf, Fuse and other servers so it will work.

Upvotes: 1

Related Questions