I am developing web service using Axis2, creating .aar file and deploying it in WSO2 Application Server. The Axis2 services deployed successfully and returns me the response as below.
<ns:serviceResponse xmlns:ns="http://service.axis.example.com">
<ns:return>{"status":"SUCCESS"}</ns:return>
</ns:serviceResponse>
But I am expecting a JSON response. Since Axis2 has support for JSON response, I tried following the below tutorial by modifying axis2.xml(Enabling messageBuilder and messageFormatter) but it was not successful.
http://axis.apache.org/axis2/java/core/docs/json_support.html
http://www.javacodegeeks.com/2012/02/json-web-service-with-java-and-axis2.html
Also,
I tried deploying wso2dynamic-response-20080916.170559-241.mar from UI (Modules Tab -> Add) and the uploaded file deployed to the following location(CARBON_HOME/repository/deployment/server/axis2modules).
And I tried copying wso2dynamic-response-1.5.jar as per suggestion in I can't to return json objects using Axis2 but still getting XML response instead of JSON.
Kindly let me know what I am doing wrong and guide to the right direction.
Thanks in Advance.
Would
JSONMessageFormatter.getJSONWriter
Help?
Enabling JSON message formatter in the axis2.xml should work..Anyway , what is your response's content type?..It should be application/json
Related
We have deployed our webservice in liberty server.Earlier it was on IBM WAS. After deploying in liberty, we came to know that Webservices is running on CXF webservice framework. In WAS, it was Axis framework.
Another difference is that , changes happened in wsdl url & content. The old wsdl url is http://localhost:8080/Hello/HelloServices/Helloservices.wsdl and it contains xsd schema definition.
In the liberty server above wsdl url is not working and throwing file not found. But if we try to invoke http://localhost:8080/Hello/HelloServices?wsdl it's working.
Could anyone tell why old url is not working in New server. Is it due to server or inbuilt cxf framework in server.
Another team is using wsdl url to consume this webservice, with this new url they are not able to achieve it.
Any thoughts or suggestions are appreciated..
Thanks in Advance
The main reason for this is the change in the JAX-WS implementations used by the different WebSphere profiles. CXF, unfortunately, hard codes the WSDL url to append ?wsdl in several locations and so this is something that is not possible to change in configuration. The easiest solution would to add a ServletFilter to check the incoming request url for http://localhost:8080/Hello/HelloServices/Helloservices.wsdl and then redirect the request to http://localhost:8080/Hello/HelloServices/Helloservices?wsdl.
There's a good SO post that shows how to write a ServletFilter to redirect here:
How to use a servlet filter in Java to change an incoming servlet request url?
The other option would be to have the client side update either their code or configuration to account for the change to the WSDL URL.
I have a project where we have developed the webservices using grails.
Here we have given the mapping in URLMappings.groovy and have controller and Services defined along with domain clasess.
When we get a request we generate an xml or json response based on the request.
Here we have not used any wsdl file.
Can anyone explain how this works in background and why we don't need a wsdl here?
have a wsdl link and I know the soap request what to send and lso the response format through the membrane soap ui client
I have written a simple html page having 3 fields which i pass through request format of soap and then i get a response based on it. This passing of request and validations are done in servlet which i call through action in form. Now i have a wsdl file link.
How should I use it to make request response from the servlet .please help me with code.
EDIT : THE WSDL CONTAINS WCF BASED SOAP SERVICE .
You have to build a web service client from wsdl using wsimport java utility, then you will get a webservice handle, using that you can build a request, send a request and get a response.
for more details: http://docs.oracle.com/javaee/6/tutorial/doc/bnayn.html
I have a base service which returns gzipped response which wso2 esb is unable to understand. So when i create a pass through proxy of the above web service and when i try to run the service in soapUI, the result that esb shows me is the wsdl file of the above service. I am unable to find out how to decompress the response sent from the base service in wso2 esb. is there any way to do it? Looking forward to your solutions. Thanks in advance.
I have a Soap based web services running in websphere 8. Since we have he trace.log, which have the Webservices request and response XML. I am trying to log it to a different file apart from trace.log.
To be very precise, If my service is HelloWorldService. I would like to log the SOAP requests in service_helloworld.log. I have defined the appenders and loggers in log 4j already. But I am looking into a way where I could configure websphere to redirect the webservices traces to that file.
I still could write a interceptor, but I am trying it in websphere configs. Please help
I don't know if you still have that problem... But I had the same one and I just fix it implementing a GenericHandler that interceps the request/response.
Take a look:
http://www.ibm.com/developerworks/websphere/library/techarticles/0511_phung-lu/0511_phung-lu.html