Hi Hans.


On Wed, Sep 28, 2011 at 1:28 PM, Hans De Clercq <
hans.de.cle...@aristomusic.com> wrote:

>  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"<http:%5C/%5C/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 ?
>
>
If this is the XML corresponding to the JSON i don't think there is any
error with generated the JSON
<ns1:loginUser xmlns:ns1="http://www.tunify.com";><userName
xmlns="">blabla1</userName><userPassword
xmlns="">blablaPassw</userPassword><appID xmlns="">15</appID><appPassword
xmlns="">password15</appPassword></ns1:loginUser>

can you provide the complete fault you received

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 :
>
> *
> [image: Twitter] <http://www.twitter.com/tunify>
> [image: Facebook] <http://www.facebook.com/tunify>
>  *
>
>
> *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*
>



-- 
Pulasthi Supun
Undergraduate
Dpt of Computer Science & Engineering
University of Moratuwa
Blog : http://pulasthisupun.blogspot.com/
Git hub profile:
<http://pulasthisupun.blogspot.com/>https://github.com/pulasthi
<https://github.com/pulasthi>

<<image/jpeg>>

<<facebook.gif>>

<<twitter.gif>>

Reply via email to