axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hodchenkov, Paul" <paul.hodchen...@oxagile.com>
Subject RE: [AXIS2] Problem: Sending JSON messages to a SOAP Web service using Axis2
Date Mon, 03 Oct 2011 12:05:03 GMT
Hi,
Nice to hear that. Related to 'Nullpointer exception in fault': It seems that output from
server is produced using pure JSON (non badgerfish), so Axis2 stub can't deserialize it. If
you want Axis2 stub to deserializa json response, please specify JSONBadgerfishFormatter for
application/json in server axis2.xml

From: Hans De Clercq [mailto:hans.de.clercq@aristomusic.com]
Sent: Monday, October 03, 2011 2:47 PM
To: java-user@axis.apache.org
Subject: Re: [AXIS2] Problem: Sending JSON messages to a SOAP Web service using Axis2

I updated the axis2.xml on the server, and it seems that the problem is solved!
If not, I'll keep you posted.

Thanks for the support!

Op 3/10/2011 12:56, Hodchenkov, Paul schreef:
Hi,

1)      Can you show the stacktrace from the server side logs?

2)      Show axis2.xml where formatters and builders are defined

From: Hans De Clercq [mailto:hans.de.clercq@aristomusic.com]
Sent: Monday, October 03, 2011 1:09 PM
To: java-user@axis.apache.org<mailto:java-user@axis.apache.org>
Subject: Re: [AXIS2] Problem: Sending JSON messages to a SOAP Web service using Axis2

The whole output is the following:

11:57:28,297 DEBUG [header][wire] >> "POST /tunify2-ws/services/tunify2?wsdl HTTP/1.1[\r][\n]"
11:57:28,329 DEBUG [header][wire] >> "Content-Type: application/json; charset=UTF-8[\r][\n]"
11:57:28,329 DEBUG [header][wire] >> "User-Agent: Axis2[\r][\n]"
11:57:28,344 DEBUG [header][wire] >> "Host: localhost:8080[\r][\n]"
11:57:28,344 DEBUG [header][wire] >> "Transfer-Encoding: chunked[\r][\n]"
11:57:28,344 DEBUG [header][wire] >> "[\r][\n]"
11:57:28,375 DEBUG [content][wire] >> "ff[\r][\n]"
11:57:28,391 DEBUG [content][wire] >> "{"ns1:loginUser":{"@xmlns":{"ns1":"http:\/\/www.tunify.com"<http://www.tunify.com>},"userName":{"@xmlns":{"$":""},"$":"blabla"},"userPassword":{"@xmlns":{"$":""},"$":"blablaPassw"},"appID":{"@xmlns":{"$":""},"$":"28"},"appPassword":{"@xmlns":{"$":""},"$":"28Passw"}}}"
11:57:28,391 DEBUG [content][wire] >> "[\r][\n]"
11:57:28,391 DEBUG [content][wire] >> "0"
11:57:28,391 DEBUG [content][wire] >> "[\r][\n]"
11:57:28,407 DEBUG [content][wire] >> "[\r][\n]"
11:57:28,422 DEBUG [header][wire] << "HTTP/1.1 500 Internal Server Error[\r][\n]"
11:57:28,438 DEBUG [header][wire] << "HTTP/1.1 500 Internal Server Error[\r][\n]"
11:57:28,438 DEBUG [header][wire] << "Server: Apache-Coyote/1.1[\r][\n]"
11:57:28,438 DEBUG [header][wire] << "Content-Type: application/json;charset=UTF-8[\r][\n]"
11:57:28,454 DEBUG [header][wire] << "Transfer-Encoding: chunked[\r][\n]"
11:57:28,454 DEBUG [header][wire] << "Date: Mon, 03 Oct 2011 09:57:28 GMT[\r][\n]"
11:57:28,454 DEBUG [header][wire] << "Connection: close[\r][\n]"
11:57:28,454 DEBUG [header][wire] << "[\r][\n]"
11:57:28,532 DEBUG [content][wire] << "1"
11:57:28,532 DEBUG [content][wire] << "0"
11:57:28,547 DEBUG [content][wire] << "9"
11:57:28,547 DEBUG [content][wire] << "[\r]"
11:57:28,547 DEBUG [content][wire] << "[\n]"
11:57:28,547 DEBUG [content][wire] << "{"Fault":{"$":"<soapenv:Fault xmlns:soapenv=\"http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\"<http://schemas.xmlsoap.org/soap/envelope/>><faultcode>soapenv:Server<\/faultcode><faultstring>org.apache.axis2.databinding.ADBException:
Unexpected subelement userName<\/faultstring><detail \/><\/soapenv:Fault>"}}"
11:57:28,563 DEBUG [content][wire] << "[\r]"
11:57:28,563 DEBUG [content][wire] << "[\n]"
11:57:28,563 DEBUG [content][wire] << "0"
11:57:28,579 DEBUG [content][wire] << "[\r]"
11:57:28,579 DEBUG [content][wire] << "[\n]"
11:57:28,579 DEBUG [content][wire] << "[\r]"
11:57:28,579 DEBUG [content][wire] << "[\n]"
11:57:28,594 DEBUG [header][wire] << "[\r][\n]"
11:57:29,922 ERROR [Application][main]
java.lang.NullPointerException
    at org.apache.axiom.soap.impl.llom.SOAPBodyImpl.getFault(SOAPBodyImpl.java:121)
    at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:530)
    at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
    at tunify2.server.Tunify2Stub.loginUser(Tunify2Stub.java:6964)
    at com.tunify.callcenterRegistration.webservice.UserCreator.loginUser(UserCreator.java:79)
    at com.tunify.callcenterRegistration.webservice.UserCreator.<init>(UserCreator.java:69)
    at com.tunify.callcenterRegistration.client.Application.execute(Application.java:92)
    at com.tunify.callcenterRegistration.client.Application.main(Application.java:49)


For setting up the ConfigurationContext I used:

File configFile = new File("axis2.xml");
ConfigurationContext confContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
configFile.getAbsolutePath());

 this._webservice = new Tunify2Stub(confContext, tunifyURL); //with tunifyURL is the url to
the WSDL
 this._webservice._getServiceClient().getOptions().setProperty(Constants.Configuration.MESSAGE_TYPE,
"application/json");


for calling the loginUser method (with a correct loginUser-object)

LoginUserResponse response = this._webservice.loginUser(loginUser);


When I change the MESSAGE_TYPE to "application/soap+xml, there is no problem, and the output
is then:
(don't mind the statuscode: invalidusername in the response, it is a correct response)

12:01:42,266 DEBUG [header][wire] >> "POST /tunify2-ws/services/tunify2?wsdl HTTP/1.1[\r][\n]"
12:01:42,297 DEBUG [header][wire] >> "Content-Type: text/xml; charset=UTF-8[\r][\n]"
12:01:42,297 DEBUG [header][wire] >> "SOAPAction: "http://www.tunify.com/loginUser"<http://www.tunify.com/loginUser>[\r][\n]"
12:01:42,297 DEBUG [header][wire] >> "User-Agent: Axis2[\r][\n]"
12:01:42,313 DEBUG [header][wire] >> "Host: localhost:8080[\r][\n]"
12:01:42,313 DEBUG [header][wire] >> "Transfer-Encoding: chunked[\r][\n]"
12:01:42,313 DEBUG [header][wire] >> "[\r][\n]"
12:01:42,594 DEBUG [content][wire] >> "2a5[\r][\n]"
12:01:42,594 DEBUG [content][wire] >> "<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"<http://schemas.xmlsoap.org/soap/envelope/>><soapenv:Header
xmlns:wsa="http://www.w3.org/2005/08/addressing"<http://www.w3.org/2005/08/addressing>><wsa:To>http://localhost:8080/tunify2-ws/services/tunify2?wsdl</wsa:To><wsa:MessageID>urn:uuid:39cd6a85-4f84-4c33-b74f-2094d4d142fb</wsa:MessageID><wsa:Action>http://www.tunify.com/loginUser</wsa:Action></soapenv:Header><soapenv:Body><ns1:loginUser
xmlns:ns1="http://www.tunify.com"<http://www.tunify.com>><userName xmlns="">blabla</userName><userPassword
xmlns="">blablaPassw</userPassword><appID xmlns="">28</appID><appPassword
xmlns="">28Passw</appPassword></ns1:loginUser></soapenv:Body></soapenv:Envelope>"
12:01:42,610 DEBUG [content][wire] >> "[\r][\n]"
12:01:42,610 DEBUG [content][wire] >> "0"
12:01:42,610 DEBUG [content][wire] >> "[\r][\n]"
12:01:42,625 DEBUG [content][wire] >> "[\r][\n]"
12:01:45,922 DEBUG [header][wire] << "HTTP/1.1 200 OK[\r][\n]"
12:01:45,938 DEBUG [header][wire] << "HTTP/1.1 200 OK[\r][\n]"
12:01:45,938 DEBUG [header][wire] << "Server: Apache-Coyote/1.1[\r][\n]"
12:01:45,938 DEBUG [header][wire] << "Content-Type: text/xml;charset=UTF-8[\r][\n]"
12:01:45,954 DEBUG [header][wire] << "Transfer-Encoding: chunked[\r][\n]"
12:01:45,954 DEBUG [header][wire] << "Date: Mon, 03 Oct 2011 10:01:45 GMT[\r][\n]"
12:01:45,954 DEBUG [header][wire] << "[\r][\n]"
12:01:46,000 DEBUG [content][wire] << "1"
12:01:46,000 DEBUG [content][wire] << "f"
12:01:46,016 DEBUG [content][wire] << "0"
12:01:46,016 DEBUG [content][wire] << "[\r]"
12:01:46,016 DEBUG [content][wire] << "[\n]"
12:01:46,016 DEBUG [content][wire] << "<?xm"
12:01:46,032 DEBUG [content][wire] << "l version='1.0' encoding='U"
12:01:46,047 DEBUG [content][wire] << "TF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"<http://schemas.xmlsoap.org/soap/envelope/>><soapenv:Header
xmlns:wsa="http://www.w3.org/2005/08/addressing"<http://www.w3.org/2005/08/addressing>><wsa:Action>http://www.tunify.com/tunify2/loginUserResponse</wsa:Action><wsa:RelatesTo>urn:uuid:39cd6a85-4f84-4c33-b74f-2094d4d142fb</wsa:RelatesTo></soapenv:Header><soapenv:Body><ns1:loginUserResponse
xmlns:ns1="http://www.tunify.com"<http://www.tunify.com>><status><statusCode>invalidUserName</statusCode></status></ns1:loginUserResponse>"
12:01:52,204 DEBUG [content][wire] << "[\r]"
12:01:52,219 DEBUG [content][wire] << "[\n]"
12:01:52,219 DEBUG [content][wire] << "2"
12:01:52,219 DEBUG [content][wire] << "2"
12:01:52,219 DEBUG [content][wire] << "[\r]"
12:01:52,219 DEBUG [content][wire] << "[\n]"
12:01:52,235 DEBUG [content][wire] << "</soapenv:Body></soapenv:Envelope>"
12:01:52,235 DEBUG [content][wire] << "[\r]"
12:01:52,235 DEBUG [content][wire] << "[\n]"
12:01:52,235 DEBUG [content][wire] << "0"
12:01:52,250 DEBUG [content][wire] << "[\r]"
12:01:52,250 DEBUG [content][wire] << "[\n]"
12:01:52,250 DEBUG [content][wire] << "[\r]"
12:01:52,250 DEBUG [content][wire] << "[\n]"
12:01:52,250 DEBUG [header][wire] << "[\r][\n]"

So in fact there are 2 problems:

 1.  The biggest problem: "Unexpected subelement userName"
the WSDL can be found at http://webservice.aristomusic.com/blackbox/services/tunify2?wsdl
 2.  the Nullpointer in the getFault method

Op 3/10/2011 11:46, Hodchenkov, Paul schreef:
Hi,
What exact error message do you have?

Also please try to send JSON request using Poster plugin in firefox (specify content-type
application/json/badgerfish)

From: Hans De Clercq [mailto:hans.de.clercq@aristomusic.com]
Sent: Monday, October 03, 2011 12:41 PM
To: java-user@axis.apache.org<mailto:java-user@axis.apache.org>
Subject: Re: [AXIS2] Problem: Sending JSON messages to a SOAP Web service using Axis2

Hi,

thanks for the answer.

I've built the source file you attached and added it to axis2.xml, but still, the problem
remains!

Op 29/09/2011 12:06, Hodchenkov, Paul schreef:
Hi,
Please find the source attached. Compile it and add to axis2.xml instead of default badgerfish
builder.

From: Hans De Clercq [mailto:hans.de.clercq@aristomusic.com]
Sent: Thursday, September 29, 2011 12:43 PM
To: java-user@axis.apache.org<mailto:java-user@axis.apache.org>
Subject: Re: [AXIS2] Problem: Sending JSON messages to a SOAP Web service using Axis2

Hi,

I suppose you mean JSONBadgerfishOMBuilder ?

is it possible to send me a modified jar ?
Or explain how I can modify JSONBadgerfishOMBuilder and what the whole processDocument method
looks like?

Thanks!

Op 28/09/2011 15:21, Hodchenkov, Paul schreef:
Hi,
According to this [1], you can't use JSON with RPCMessageReceiver.
I modified JSONBadgerfishBuilder to handle this case by converting JSON/Badgerfish explicitly
to SOAP:
public OMElement processDocument(InputStream inputStream, String contentType,
                                     MessageContext messageContext) throws AxisFault {
....
    AbstractXMLInputFactory inputFactory = createFactory();
            XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(
                    new JSONTokener(IOUtils.toString(reader)));
            OMNodeEx document = (OMNodeEx) new StAXOMBuilder(xmlReader).getDocumentElement();
            //removing parent
            document.setParent(null);
            //wrapping document with envelope
            SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
            SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope();
            SOAPBody body = soapEnvelope.getBody();
            body.addChild(document);

            soapEnvelope.build();

...
}

[1] http://isurues.wordpress.com/2009/10/06/how-to-use-axis2-json/


--
[cid:image001.jpg@01CC81DD.D3FBC5B0]
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<http://www.tunify.com/>

FOLLOW US ON :
[cid:image002.gif@01CC81DD.D3FBC5B0]<http://www.twitter.com/tunify>
[cid:image003.gif@01CC81DD.D3FBC5B0]<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








---------------------------------------------------------------------

To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org<mailto:java-user-unsubscribe@axis.apache.org>

For additional commands, e-mail: java-user-help@axis.apache.org<mailto:java-user-help@axis.apache.org>

--
[cid:image001.jpg@01CC81DD.D3FBC5B0]
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<http://www.tunify.com/>

FOLLOW US ON :
[cid:image002.gif@01CC81DD.D3FBC5B0]<http://www.twitter.com/tunify>
[cid:image003.gif@01CC81DD.D3FBC5B0]<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

--
[cid:image001.jpg@01CC81DD.D3FBC5B0]
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<http://www.tunify.com/>

FOLLOW US ON :
[cid:image002.gif@01CC81DD.D3FBC5B0]<http://www.twitter.com/tunify>
[cid:image003.gif@01CC81DD.D3FBC5B0]<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

--
[cid:image001.jpg@01CC81DD.D3FBC5B0]
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<http://www.tunify.com/>

FOLLOW US ON :
[cid:image002.gif@01CC81DD.D3FBC5B0]<http://www.twitter.com/tunify>
[cid:image003.gif@01CC81DD.D3FBC5B0]<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

Mime
View raw message