Hi, I currently have a SOAP Web service in Axis2! For using the web services for mobile applications I'm trying to send the messages in JSON. This way, less text has to be send. (I know it's probably better for using rest + json, but now I'm looking for a quick temporary fix) I have a generated client (with a stub), which generates soap messages, sends the messages and parses the response. All this in xml. I'm trying to alter this so I can send JSON messages instead of xml. What have I done? : - in axis2.xml : added [CODE] <messageFormatters> <messageFormatter contentType="application/json" class="org.apache.axis2.json.JSONBadgerfishMessageFormatter"/> <!-- more message formatters --> </messageFormatters> <messageBuilders> <messageBuilder contentType="application/json" class="org.apache.axis2.json.JSONBadgerfishOMBuilder"/> <!-- more message builders --> </messageBuilders>[/CODE] - In the client code: [CODE]File configFile = new File("axis2.xml"); ConfigurationContext confContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, configFile.getAbsolutePath()); this._webservice = new Tunify2Stub(confContext, tunifyURL); this._webservice._getServiceClient().getOptions().setProperty(Constants.Configuration.MESSAGE_TYPE, "application/json"); this._webservice._getServiceClient().getOptions().setTimeOutInMilliSeconds(2*60*1000); this.loginUser(credentials);[/CODE] the Tunify2Stub constructor uses the configurationContext and the url of the WSDL - the loginUser method basically does: [CODE] LoginUserResponse response = this._webservice.loginUser(loginUser);[/CODE] with the correct loginUser object. When I run this code with de messageType "application/soap+xml" there is no problem. The request is handled perfectly. But when I change the messageType to "application/json" (used in axis2.xml), I guess the request is parsed to JSON and sent to the server, but then I receive a fault of "unexpected subelement ..." , which is the case when the server receives a request which is in conflict with the wsdl. Does anyone know a possible reason for this ? I tried many things and searched a long time on the web, but no solution. my json request looks like this: [CODE]"{"ns1:loginUser":{"@xmlns":{"ns1":"http:\/\/www.tunify.com"},"userName":{"@xmlns":{"$":""},"$":"blabla1"},"userPassword":{"@xmlns":{"$":""},"$":"blablaPassw"},"appID":{"@xmlns":{"$":""},"$":"15"},"appPassword":{"@xmlns":{"$":""},"$":"password15"}}}"[/CODE] Is there something wrong with the construction of the generated JSON ? Thanks in advance!! --
![]() Met vriendelijke groeten I Hans De Clercq I R&D Aristo Music NV I Interleuvenlaan 15 F I B - 3001 Heverlee I + 32 498 301007 I www.tunify.com
FOLLOW US ON :
CONFIDENTIALITY: This email (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited. If you received this email in error, please notify the sender and delete this email from your system |
- [AXIS2] Problem: Sending JSON messages to a ... Hans De Clercq
- Re: [AXIS2] Problem: Sending JSON messa... Pulasthi Supun Wickramasinghe
- Re: [AXIS2] Problem: Sending JSON messa... Charles Galpin
- RE: [AXIS2] Problem: Sending JSON m... Hodchenkov, Paul
- Re: [AXIS2] Problem: Sending JS... Hans De Clercq
- RE: [AXIS2] Problem: Sendin... Hodchenkov, Paul
- RE: [AXIS2] Problem: S... Hodchenkov, Paul