I am using axis2 to create a web service from a java class I created. Everything works well, but I'd like to be able to customize the wsdl and I cannot figure out how to do it. I tried using some JAXB annotations with my objects (using axis1) but it had no effect on the wsdl generation.
I'd like to be able to specify nillable=true for some elements and make others required. I'd also like to be able to change element names and other things. Shouldn't axis2 look at the JAXB2.0 annotations if there's no WSDL included in the META-INF folder?
I have been trying to google how to map out the schema in a bottom-up approach but I have not had luck. The axis2 website only shows basic steps for creating a web service or a client, but nothing about customizing the schema.
To use JAXB annotation with AXIS2, you should have a look at this article :
Java Web services: JAXB and JAX-WS in Axis2
In Eclipse.org you find (Eclipse Helios) Eclipse IDE for Java EE Developers which is useful to create a web service easily and you can look at the documentation once for use of it effectively.
Related
I need help of awesome tech people here. I'm trying to understand if I can generate a webservice stubs or class automatically using the wsdl file or is it possible to auto detect the methods or services available on the server side. My web application needs to detect these service methods, type of arguments they accept etc.
I know of some tools like wsdl2java or wsimport, but for this, I need to manually run some commands to generate the client stubs. Instead, I'm looking for a solution, where I can upload the wsdl file to my web application and my application can auto generate the java files, integrate it inside the application and start using it. Not sure if this is possible, but this is my requirement.
Please provide your suggestion or guide me to understand the do's or don'ts here. Many thanks.
take a look to this page :
Dynamic Web service invocation from a WSDL : http://www.computing.dcu.ie/~mwang/DI/di.html
I have the following requirements and thinking about how to best get java objects from a WSDL.
XML data comes from a public SOAP Webservice
I have to use JAXB
I want to automatically unmarshall the retrieved data to Java objects
Ideally I'd like to have java objects using JAXB Annotations. Are there any tools that I could combine to autogenerate these?
Sure, there are lots of ways to use JAX-WS (which uses JAXB for its XML binding) to generate a web service client.
You can execute it from the command-line:
http://www.mkyong.com/webservices/jax-ws/jax-ws-wsimport-tool-example/
As part of your Maven build:
https://jax-ws-commons.java.net/jaxws-maven-plugin/
Or from within your Eclipse environment:
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.jst.ws.cxf.doc.user%2Ftasks%2Fcreate_client.html
Yes, there are. With every jdk, there is an executable file called wsimport that does exactly what you want.
Here is an answer i gave to a similar question.
I'd like to know if it's possible to create Web Services client from a WSDL file using Spring Web Services.
I mean from the very WSDL, I don't have any XSD for the time being.
But I've read Josh Long's "Spring Recipes A Problem-Solution Approach", Hamidreza Sattari's "Spring Web Services 2 Cookbook" and the tutorial itself (6. Using Spring Web Services on the Client) and there's no reference to this feature.
I've also read other posts, like Webservice-Client: Common approach with Spring WS, JAXB and just one WSDL file?, or Spring-ws client from WSDL (here at stackoverflow) but without any further results.
I've even asked the question at Spring forums, but no responses after more than 60 reads: Is it possible to create a WS-client from WSDL file using SWS? (It seems not)
Maybe it's not possible.
Thanks.
You can do it this way:
Generate your java types using the xjc tool that comes with the JDK distributions - xjc -wsdl file.wsdl
Then using the generated java types, use WebserviceTemplate, described here to create the client.
I'm writing a web service using jax-ws. One of web service's methods returns bean, which contains reference to its parent. To prevent cyclic references I'm using JAXB #XMLID and #XMLIDRef annotations in my bean.
Then i'm generating proxy class for java client everything works OK and id resolves to Object properties. But then I'm generating web-service client proxy in Visual Studio for .NET, it interprets idrefs as string properties, not an Object.
Is it possible to generate proxy classes from wsdl for .NET with resolving of idrefs?
Out of the box Microsoft's tools won't do the job for you. You'll have to ask Microsoft to change the
wsdl generation tools. E.g.:
wsdl.exe: http://msdn.microsoft.com/library/7h3ystb6(VS.80).aspx
svcutil.exe: http://msdn.microsoft.com/en-us/library/aa347733.aspx
In a recent project I had to work around the short comings of these tools and modified the generated code using a Basic Script fixing what was not generated the way needed (in our case incompatibilities with the Java side wsdl generation)
I need to create connection to web service with axis2. I would like to know how can I convert recieved xmls to Java objects. Is there any good tutorials to learn how to do this?
Axis2 is pretty well documented. Make sure to check the axis2 user guide.
On the other hand be aware of that using web services and axis2 is not a piece
of cake sort of think, so read the docs exhausitvly. ;)
Either the XML is part of the SOAP request. In that case, Axis2 will convert it to Java for you.
If XML is part of a "data blob", then you need to do this yourself. There are several options:
You can have a look at the generators which Axis2 uses. Try the docs.
Use an XML OO mapper like Castor.
You can write your own mapper (not really recommended).
If you can influence the sender side, you can try to create XML that follows the rules for XMLEncoder. That would allow you to use the standard Java Serialization API to build objects.
use axis wsdl2java tool and put generated classes to your source files. Then first create a service stub with YourServiceStub(Service_Adress) and use that instance to invoke necessary methods.
for wsdl2java i commonly use:
wsdl2java -uri wsdlLocation -ss -sd -uw -g -o outputLocation