I'm using JaxWs/JaxB in a webservice, but I don't like the fact that all my xml files (be it the ones I send or receive) contain SOAP envelopes. How can I get rid of those?
All I need is a clean xml file that the web service returns without any SOAP envelope. That part of the xml file is redundant in my case.
I have spent several days on this, but I just can't seem to get rid of it.
jaxws is a technology for creating webservices using the SOAP protocol, which by definition includes the SOAP envelope. if you don't want the SOAP envelope, don't use jaxws/SOAP. you could instead use one of the jaxrs related technologies (e.g. jersey), or you could simply implement a servlet which accepts xml data.
You can use JIBX for this purpose: http://jibx.sourceforge.net/
Related
I was wondering if it was actually possible to create a Java SOAP Webservice without using it's WSDL.
Context:
The idea is that I have to mock a webservice, so I have its WSDL. The mock will only read the soap request, search if there are any similar request (as key in a map) and send the matching response (as its value). This is for automated testing purpose. The problem is not the "map" part.
Anyway, I've been using Axis and eclipse to generate classes and files and load them in tomcat from the WSDL. So far it've been a mess, with a lot of compatibility issues between these components. And it's gonna be much more difficult to compare the input or serialize the output to do what I want this way.
I thought about creating a REST endpoint and send the soap request through it (so I would directly get the SOAP request !), but I rode somewhere that soap request weren't valid and wouldn't be retreived by the REST endpoint... Also, won't the client application throw an error if there is no WSDL at this address ?
My question is:
Is there a way to create an access point, that looks like a SOAP Webservice (from clients), but which allows me to get the full soap request (as a String for example) and send a response (still as a String) inside a Java app?
Complements:
I'm looking for something, a library, maybe just an annotation on Servlets, that doesn't needs (if possible) to generate a huge load of classes and xml files everywhere. The app would be running on tomcat (but I can be a basic Java app). Using maven and spring wouldn't be a problem.
Thanks in advance !
Normally, clients do not require an WSDL. But it is a nice feature - use a normal servlet and handle the "?WSDL" manually. Then use some simple XPath or parse logic to extract the payload as a DOM document.
I have to request a PHP page with 3 Parameters (e.g. www.test.com/index.php?name=mrTest&no=1&id=10001). I'm using WSDL2JAVA for other Services and am now wondering if it is possible to generate a similar Service for this case. This PHP page Returns an XML. I'm just consumer/client of the Service.
I could also make a simple request and then use JAXB to parse the XML but i would like to implement all my Services the same way.
So, does anybody has already implement a php page consumer using WSDL2JAVA?
Best regards
So from my understanding this is a simple PHP page not a SOAP service. Remember XML is just the protocol used in a SOAP service however a SOAP service consists out of a WSDL that is published describing operations and how to call those operations.
A simple PHP page even if it returns XML data is NOT a SOAP service and thus does NOT have a WSDL. You wont be able to use WSDL2JAVA for that.
This PHP page seems more like a REST type service that returns XML instead of JSON. To be honest it really sounds like a REST service.
Try using the latest SOAPUI to connect to the page and see if you can use the REST project type with this page. If it is a REST service it might have a WADL file. YOu can use the WADL2JAVA cxf utility to generate classes to you. HOwever this is a BIG might as most REST services dont use WADL's yet. See this link on CXF
I work with REST service provided by RESTeasy. It's REST, so there is no WSDL, right? Does that mean that I have to write all entities on my own and do unmarshalling on my own?
If it would be rest service, I could just download WSDL and then generate client from it. How do i do it with REST, that is served as xml in Atom feed?
I don't really see any advantage in REST, if it has no way of generating client and doesn't provide any public specification of entities.
Thank you for your help.
Correct, with REST, there's no WSDL like there's with SOAP. That does not mean there's no unmarshalling directly to objects however. You can still use Jax-RS to bind the JSON/XML to an object, so you'll have the flexibility of mapping directly like you would in SOAP, you just need to build this class rather than letting SOAP build it for you.
Consider the example here
I wish to consume a SOAP webservice from the Govt. of India public data sets. Here is an sample URL:
http://data.gov.in/sites/default/files/Fish_2013.xml
I have been using REST APIs and have never used a SOAP one.This is a SOAP webservice and it does not give me any information about the wsdl file location. As per my understanding I can generate a client using the WSDL if available and use it but how do I use a SOAP API without WSDL.
Most of the other posts talk about changing the response format but then its not possible in my case.
You can do 2 tricks:
install a local webserver
map the localhost/yourproject?wsdl to that xml file
use a Soap client generator tool on that wsdl link ( some allow other links wich doesn't end at wsdl some doesn't)
use the generated artifacts to consume soap.
I'm writing a bridge between two old application on our network. One has a webservice that takes URL encoded parameters (GET) and returns an XML document. Like this:
http://mytest.com/getData/?format=xml&dateStart=2012-01-01
My question is this - I can use the XSD for the xml returned and marshall it into Java objects (xjc defined).. but is there any way to map the requests/responses to a jax-ws webservice (or similar?) It's not SOAP - so I can't go the WSDL, CXF/JAX-WS route, can I?
I was really hoping for an elegant solution to this without having to code it all from scratch (URL request , returned stream, then marshal). Is there a framework out there that would allow me configure a request? I thought WSDL supported verb="GET" but sadly, I can't seem to get it working with Apache CXF and WSDL2JAVA.
Am I totally off base here?
I think JAX-RS may be of use here. Just create XSD schemas and convert them to Java classes, and use a REST client for that site.
You can probably do it with CXF too. See here.
Check out WSGen or you can add ?WSDL to the end of your JAX-WS endpoint to get the generated WSDL. This way all you have to do is create your JAX-WS annotated classes similar to your JAX-RS ones and the WSDL is generated and it should be able to handle your XJC generated objects with no problems.
http://metro.java.net/guide/ch02.html#create-a-metro-web-services-endpoint