2

Well, I've created a webservice that i can find accessing locally at:

http://127.0.0.1:8080/myapp/WSPA?wsdl

Now i need to test my webservice by calling it from another java application to verify it its working fine. I've seen that its working using WebService Client from JBoss plugin on eclipse. But the problem is that i have a method wich recieves a list of SoapFile containing a String and array of bytes. And i need to verify if its working.

@XmlType public class SoapFile implements Serializable { private String fileName; private byte[] fileData; public String getFileName() { return fileName; } public void setFileName(String fileName) { this.fileName = fileName; } public byte[] getFileData() { return fileData; } public void setFileData(byte[] fileData) { this.fileData = fileData; } } 

I've not found how to create a simple webservice client that consumes that service to test. I would like some direction for this... Tutorial or some website that explains how to make it step by step. How can i create a java client for this webservice?

2
  • Use httpclient library to write client for your service. Commented Jan 18, 2013 at 12:43
  • I think most IDE's have a built in option which uses wsimport, making your task quite easy. Commented Jan 18, 2013 at 12:44

3 Answers 3

2

Igor, just use wsimport with your web service url - you will get generated classes for WebService and then just invoke service in that way:

ServiceGenerateFromWSImportWhichIsTheSameAsYour iService = new ServiceGenerateFromWSImportWhichIsTheSameAsYour(). getServiceGenerateFromWSImportWhichIsTheSameAsYourPort(); // now on iServie instance you can invoke method from your webservice // but you have to use stub classes generated by wsimport iService.myMethodWhichGetFileList(List<SoapFileStubGeneratedClass> sopaFiles); 

And wsimport is standard java tool in jdk instal folder

More on wsimport tool you can find here:

wsimport doc

Using wsimport in your case will be:

wsimport -p generated_classes -s generated_sources http://127.0.0.1:8080/myapp/WSPA?wsdl 

and you will find .class files in folder generated_classes and .java files in folder generated-sources

Sign up to request clarification or add additional context in comments.

9 Comments

SOAPUI (both free or paid version) are a great help too. SoapUI can generate the client files as well, and are useful for testing.
I've tried that wsimport and got this message: directory not found: generated_sources
so create those directories first
one mistake -p generated_class means package name to be created (folder with that name is just the effect of creating package structure) so it will be better to use -p your_app_name
I've changed the generated_class to my project name... and now im getting "directory not found: generated_sources"
|
1

Do you have a WSDL file. If yes then you can use IDE like eclipse to generate client stub.

Below link will also be a good place to start

http://docs.oracle.com/cd/E17802_01/webservices/webservices/reference/tutorials/wsit/doc/Examples_glassfish6.html

Comments

0

A "Hello World" Tutorial with wsimport for Jax-WS can you find here

Tim

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.