wood burning stoves 2.0*
The moose likes Web Services and the fly likes Web service proxy client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Web service proxy client" Watch "Web service proxy client" New topic
Author

Web service proxy client

forums UseR
Ranch Hand

Joined: Feb 24, 2009
Posts: 169
Hello,

I am new to JEE and JAX-WS.

I generated a client from the webservice interface. It automatically created all the java classes for me.

I am writing a simple test class with "main method" to call this web service method.

I get null pointer exceptions.

Here is my code:

public class DoeWsClientTest {
@WebServiceRef(name="SalesOrderCreate_Out_Service")
static SalesOrderCreateOutService service;

/
@param args
/
public static void main(String[] args) {
// TODO Auto-generated method stub
SalesOrderCreateOut servicePort = service.getPort(com.....SalesOrderCreateOut.class);


I get null pointer exception on the bold line above
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
Hi. If you are using NetBeans/GlassFish, then please see if this helps: http://www.coderanch.com/t/491830/Web-Services/java/JAX-WS-WebServiceRef-injection-NullPointerException
forums UseR
Ranch Hand

Joined: Feb 24, 2009
Posts: 169
R Srini wrote:Hi. If you are using NetBeans/GlassFish, then please see if this helps: http://www.coderanch.com/t/491830/Web-Services/java/JAX-WS-WebServiceRef-injection-NullPointerException


Hi Srini,

I am not using NetBeans/GlassFish.

BTW, where can I get the URL for the wsdl file?

Maybe I am using a wrong URL for the wsdl file...
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
Hi Srinivas. The answer depends. Please see here for an explanation and possible answer.

As you can see in your code, you are not actually creating an instance of SalesOrderCreateOut like this:

SalesOrderCreateOut x = new SalesOrderCreateOut();

However, for your program to run, you need an instance of the class, right? So either you can create it with an extra line of code , or the runtime environment will need to "inject" an instance of your class. And once the class is available to the code, your code should work (barring other issues).

In the absence of a container/context (I mean like JBoss or WebLogic or Websphere) to inject a new instance of your class, you may need to instantiate the class yourself. Hence my question: What environment are you using?

In any case, e.g. if you are using JBoss or WebLogic or Websphere, use those names when searching and you should find something. As an example, you can search for "JBoss @webserviceref nullpointerexception" and you will find some answers for sure.
forums UseR
Ranch Hand

Joined: Feb 24, 2009
Posts: 169
Hi Srini,

Thanks for your observation.

I tried to instantiate the service class
SalesOrderCreateOutService service = new SalesOrderCreateOutService();

I get exception



I can open the wsdl file and it is well formed.
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
Ok. So it can't find the wsdl. I see that the path contains "Documents and Settings". In certain situations, files with spaces in the path can create problems. So to start with, I would suggest creating the project in a location other than the default suggested by your IDE. Please try this and see if it works out. The problem might go away.

Also, you can modify the wsdl location in the client code.
forums UseR
Ranch Hand

Joined: Feb 24, 2009
Posts: 169
Hi Srini,

I moved the wsdl file to C:/

Still get same error.

How to get/find the URL for the wsdl ?
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
I am not using NetBeans/GlassFish

What exactly are you using?

I moved the wsdl file to C:/

Did you also regenerate the client code? Just want to be sure.

What is the JDK version?

Try this program, replace the file path with the wsdl file path, and see if you are able to read the wsdl file. This problem can also happen if the full path is very deep. You can try shortening the path. But in summary, this error "The system cannot find the path specified" simply means the it can't find the file.

Lastly, try adding the wsdl location in the web service like so:
@WebService (wsdlLocation="c:\")
public class MyWebService {}
forums UseR
Ranch Hand

Joined: Feb 24, 2009
Posts: 169
What exactly are you using?

eclipse
Did you also regenerate the client code? Just want to be sure.

yes, I generated the client code.

I am using a stateless session bean to call the web service, instead of a simple class (with main)



The above seems to be the problem. I am struggling to find the URL for the wsdl, so I can use "wsdlLocation=<URL for the WSDL>"
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
Ok. Eclipse. And what is the web service backend engine (e.g. Axis or GlassFish)? And JDK version? I need the information to duplicate your issue.

Regarding the WSDL file URL, you can try adding a forward slash (/) after c:/ like this: wsdlLocation="C://SalesOrderCreate_Out.wsdl" So maybe you can try that. Please first use the link from my previous post to make sure that you can open the file with the exact same path.

The actual WSDL URL: That depends on several variables. The developer of the web service should be able to tell you that. Before writing a client, you should at least be able to see the wsdl in a browser. Is there a tutorial or web page link you are working through? I can try to run the same tutorial if you like. I would suggest starting with a tutorial since all of this JAX-WS, Axis ... etc. stuff - while its not hard, it is not trivial either, and it takes quite a bit of work to get it running. Best of luck!
forums UseR
Ranch Hand

Joined: Feb 24, 2009
Posts: 169
R Srini wrote:Ok. Eclipse. And what is the web service backend engine (e.g. Axis or GlassFish)? And JDK version? I need the information to duplicate your issue.

Regarding the WSDL file URL, you can try adding a forward slash (/) after c:/ like this: wsdlLocation="C://SalesOrderCreate_Out.wsdl" So maybe you can try that. Please first use the link from my previous post to make sure that you can open the file with the exact same path.

The actual WSDL URL: That depends on several variables. The developer of the web service should be able to tell you that. Before writing a client, you should at least be able to see the wsdl in a browser. Is there a tutorial or web page link you are working through? I can try to run the same tutorial if you like. I would suggest starting with a tutorial since all of this JAX-WS, Axis ... etc. stuff - while its not hard, it is not trivial either, and it takes quite a bit of work to get it running. Best of luck!


I was able to open the file with the same path C:/SalesOrderCreate_Out.wsdl
I used C://SalesOrderCreate_Out.wsdl , now I get null pointer exception, when I deploy the project.


The application server is SAP PI 7.11 , JDK is 1.6
Thanks a lot
Srinivas
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
LOL. I know nothing about SAP - as I am sure you suspected You are better off inquiring about this in a SAP PI forum. Here are a couple of related links:

- https://forums.sdn.sap.com/message.jspa?messageID=7707041
- https://forums.sdn.sap.com/thread.jspa?threadID=1284821 (this one has more links that look promising)

Maybe it helps. Best of luck! Please post your resolution once you have it so it may be useful to others. Thanks/
forums UseR
Ranch Hand

Joined: Feb 24, 2009
Posts: 169
R Srini wrote:LOL. I know nothing about SAP - as I am sure you suspected You are better off inquiring about this in a SAP PI forum. Here are a couple of related links:

- https://forums.sdn.sap.com/message.jspa?messageID=7707041
- https://forums.sdn.sap.com/thread.jspa?threadID=1284821 (this one has more links that look promising)

Maybe it helps. Best of luck! Please post your resolution once you have it so it may be useful to others. Thanks/


Hi Srini,

Thanks for the helpful links...

I was able to deploy my EAR project, when I test my web service, I get an exception:

javax.ejb.EJBException: (Failed in component: sap.com/HeaderProxyEAR) Exception raised from invocation of public java.lang.String com...doe.salesheader.DoeToSapBean.doeHeader(java.lang.String) method on bean instance com...doe.salesheader.DoeToSapBean@4b588a1d for bean sap.com/HeaderProxyEAR*annotation|HeaderProxyEJB.jar*annotation|DoeToSapBean in application sap.com/HeaderProxyEAR.; nested exception is: javax.xml.ws.WebServiceException: java.lang.ClassCastException: class com.sap.engine.services.jndi.persistent.UnsatisfiedReferenceImpl:service:naming@com.sap.engine.boot.loader.ResourceMultiParentClassLoader@456d3d51@alive incompatible with interface com.sap.engine.services.webservices.espbase.xi.ESPXIMessageProcessor:library:webservices_lib@com.sap.engine.boot.loader.ResourceMultiParentClassLoader@1e6ee98@alive

Any clue what this exception means...
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
Srinivas, unfortunately I have no idea. This is specific to the SAP PI deployment infrastructure. You would have to ask in the SAP forum, which you seem to have done already. So just wait for a reply. Or you could try a tutorial from the SAP documentation, and then go from there. Have you looked at this? It was in the second link from above.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web service proxy client