I have written a simple java class as shown below :
public class Simple {
public String echo(String rest) {
return rest;
}
}
I have written a Simple Services.xml file and deployed it inside the META-INF Folder and generated the .aar file for this and deployed it inside the Axis2 war file , and i got a wsdl from this
for example say
http://localhost:8080/axis2/services/SimpleService?wsdl
Now my question is , i have seen some examples where , java2wsdl.bat is uesd with the combination of Java File ( wsdl2java -cn javaclass file) , which then generates the wsdl file from this java class .
Please tell me what is the correct approach to generate the wsdl file , so that i can write a client for it and deploy it as a war file ?
Please share your ideas . Thank you very much in advance .
you need to deploy it as a service if you need to create a web service. So that others can access as well. But you intention is only to generate the wsdl file java2wsdl tool is enough.
Related
I'm new in SOAP.
I must communicate with external company by using SOAP Web Services like following use case :
external company send to me soap request (ex : ask for destinataire list) and I send back data.
So, to do that they provide me wsdl file
After reading a lot of tuto, soap is little confuse for me.
Can you confirm that "Consuming Web service" part is for external comapny ex : https://spring.io/guides/gs/consuming-web-service/
And "producing web service" part is for me ?
https://spring.io/guides/gs/producing-web-service/
External company ask me to indicate url with wisdl file ... I don't understand what they mean
Where do I copy wisdl file in my code (Which folder ? I use Eclipse) ?
Must I code all methods defined in wsdl file (I don't use all of them) ?
Do I need xsd files as I can see in tuto or is it for "consuming ws " part ?
OK,
Q1: in folder defined in config file
Q2: No
Q3: No
sources : How to use WSDL with spring-boot?
I was given a WSDL file as well as the URL of corresponding web service. I know that I must convert the WSDL file to Java classes, using a tool like wsimport. But after that, I am quite lost. How do I write the client code to use these generated classes? I have been googling and still quite not sure about it.
Thanks.
You can use Apache CXF wsdl2java command to convert wsdl file to java file. After that usage is quite simple as follows(and there are may tutorials available):
HelloService service = new HelloService();
Hello client = service.getHelloHttpPort();
String result = client.sayHi("Joe");
WSDL2Java link: http://cxf.apache.org/docs/wsdl-to-java.html
CXF Client Tutorial: http://cxf.apache.org/docs/how-do-i-develop-a-client.html
Thanks.
I am trying to upload a file using web service (web service is required). Here is my server code. Here is my client code. The wsdl is here (I used XML online formater to beautify it but it trimmed the wsdl: part
I keep getting the following trace stack complaining about my file
rg.apache.axis2.AxisFault: java.io.File
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:446)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:371)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at server.ServerStub.uploadFile(ServerStub.java:175)
at client.Client.main(Client.java:53)
I have noticed that in the stub file, the File class is not a java.io.File but public static class File implements org.apache.axis2.databinding.ADBBean
How can I make the service understand the standard File.io?
Regards
I have created a pojo as below.
package demo;
public class HelloWorld {
public String sayHello(String name) {
return "Hello " + name;
}
}
I placed it in axis2 war and opened
http://localhost:8080/axis2/services/listServices.
Axis 2 is indicating it as faulty service
Faulty Services
<TOMCAT-DIR>\webapps\axis2\WEB-INF\pojo\demo\HelloWorld.class
But when I remove package declaration statement and place it on below location, everything works fine
<TOMCAT-DIR>\webapps\axis2\WEB-INF\pojo\HelloWorld.class
Now there are two possibilities
Package declaration is not allowed in pojo (and I don't believe this).
I am missing something.
Can anyone guide me?
In the book "Apache Axis Web Services, 2nd Edition", author described that when exposing a pojo class as a web service by dropping in into pojo folder, pojo class must be defined in default package.
When pojo class is defined some package, following link is helpful.
http://axis.apache.org/axis2/java/core/docs/pojoguide.html
Thanks to shashankaholic for sharing this link.
I am using Axis2 for developing webservices .
I started from WSDL file , and used WSDL2Java command line and generated all the sever related code (Skeltons) , wrote services.xml file , modified the skelton ( Implemented business logic in it ) and deployed as .aar file inside the Services folder of Axis2.war .
Now my question is
I have seen some examples using .wsdd file with Axis2 Webservices , i am really confused with this , please tell me do we need .wsdd file ??
Axis2 uses services.xml as the descriptor file.
You do not need to have .wsdd files with Axis2 - its been used in Axis..
In Axis 1 we use wsdd file. While in Axis2 we use services.xml or sun-jaxws.xml file.
You don't want .wsdd file in Axis2 , To understand the migration from Axis 1.x to Axis2 and the improvements in Axis2 in comparison with Axis1 visit Apache Axis article : https://axis.apache.org/axis2/java/core/docs/migration.html