axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Veithen <andreas.veit...@gmail.com>
Subject Re: Axis2 - JSON mapped - namespace (mismatch)
Date Tue, 01 May 2012 22:12:29 GMT
On Tue, May 1, 2012 at 5:35 PM, Andreas Veithen
<andreas.veithen@gmail.com> wrote:
> On Mon, Apr 30, 2012 at 20:54, Shameera Rathnayaka
> <shameerainfo@gmail.com> wrote:
>> Hi Matthias,
>>
>>> org.apache.axis2.json.AbstractJSONOMBuilder line 111
>>>         /*
>>>         Now we have to read the localname and prefix from the input stream
>>>         if there is not prefix, message starts like {"foo":
>>>         if there is a prefix, message starts like {"prefix:foo":
>>>          */
>>>                                         :
>>>             //if the part we read ends with ", there is no prefix,
>>> otherwise it has a prefix
>>>                                         :
>>>                     prefix = localName.substring(1, localName.length())
+
>>> ":";
>>>
>>
>>
>>>                                       :
>>>
>>>
>>> What are these prefixes used for (separated by colon) if they have nothing
>>> to do with namespaces?
>>> Are they part of some JSON format?
>>
>>
>> Yes, This is for handle namespaces in badgerfish convention. where it
>> separate prefix and localname by a ':' colon.
>>
>>>
>>>
>>> And finally, is there a "fundamental" reason why:
>>>         “Mapped” formatted JSON with namespaces are not supported in
Axis2
>>
>>
>> Axis2 uses Axiom as XML info-set representation for SOAP messages. That
>> means, to process the request it should have clear XML info-set with it. It
>> is not possible to know the namespace mappings used on one side of the
>> transport to the other side when we use mapped convention.
>
> Actually this may be much simpler to implement than we thought. I
> modified the code so that it now uses the new feature introduced by
> AXIOM-399. This means that the OMDataSource is expanded when the name
> of the element is first requested. I would expect that this occurs in
> the code that dispatches to the service operation. At that point the
> service should already be set in the message context. If that is
> correct, then this means that at the time the OMDataSource is
> expanded, the service to which the request is dispatched is already
> known. We could then get the namespace mappings from a service
> parameter that the user must configure in services.xml.

I did a quick test and it appears that there are two locations where
Axis2 attempts to get the name of the element in the SOAP body
(causing expansion of the OMSourcedElement for JSON). The first one is
here:

	at org.apache.axis2.json.AbstractJSONDataSource.getReader(AbstractJSONDataSource.java:50)
	at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.forceExpand(OMSourcedElementImpl.java:253)
	at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.ensureLocalNameSet(OMSourcedElementImpl.java:494)
	at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.getLocalName(OMSourcedElementImpl.java:500)
	at org.apache.axiom.soap.impl.llom.SOAPBodyImpl.getFirstElementLocalName(SOAPBodyImpl.java:224)
	at org.apache.axiom.soap.impl.llom.SOAPBodyImpl.hasFault(SOAPBodyImpl.java:99)
	at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.hasFault(SOAPEnvelopeImpl.java:288)
	at org.apache.axis2.context.MessageContext.isFault(MessageContext.java:4303)
	at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:154)
	at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:176)
	at org.apache.axis2.transport.http.HTTPWorker.service(HTTPWorker.java:307)
	at org.apache.axis2.transport.http.server.AxisHttpService.doService(AxisHttpService.java:281)
	at org.apache.axis2.transport.http.server.AxisHttpService.handleRequest(AxisHttpService.java:187)
	at org.apache.axis2.transport.http.server.HttpServiceProcessor.run(HttpServiceProcessor.java:82)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:680)

This is very early in the processing (when the service has not yet
been determined) and the purpose is to check if the message contains a
SOAP fault. One may wonder why the code the element name instead of
the element type (SOAPFault). This appears to be related to a
particular optimization that is important in another scenario. I think
that this can be improved so that it interacts better with the feature
introduced by AXIOM-399, i.e. so that it doesn't require expansion of
the OMSourcedElement.

The second location is here:

	at org.apache.axis2.json.AbstractJSONDataSource.getReader(AbstractJSONDataSource.java:50)
	at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.forceExpand(OMSourcedElementImpl.java:253)
	at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.ensureLocalNameSet(OMSourcedElementImpl.java:494)
	at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.getLocalName(OMSourcedElementImpl.java:500)
	at org.apache.axiom.soap.impl.llom.SOAPBodyImpl.getFirstElementLocalName(SOAPBodyImpl.java:224)
	at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.getSOAPBodyFirstElementLocalName(SOAPEnvelopeImpl.java:297)
	at org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher.findOperation(SOAPMessageBodyBasedDispatcher.java:54)
	at org.apache.axis2.engine.AbstractDispatcher.invoke(AbstractDispatcher.java:106)
	at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:335)
	at org.apache.axis2.engine.Phase.invoke(Phase.java:308)
	at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:262)
	at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:168)
	at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:176)
	at org.apache.axis2.transport.http.HTTPWorker.service(HTTPWorker.java:307)
	at org.apache.axis2.transport.http.server.AxisHttpService.doService(AxisHttpService.java:281)
	at org.apache.axis2.transport.http.server.AxisHttpService.handleRequest(AxisHttpService.java:187)
	at org.apache.axis2.transport.http.server.HttpServiceProcessor.run(HttpServiceProcessor.java:82)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:680)

This is exactly where I expect, namely in the code that identifies the
operation. At this point the service is already known, so that
JSONDataSource would be able to get a namespace map from the service
configuration.

>> Thanks
>> Shameera.
>>
>>>
>>> Or is it just a resource issue, and someone (may be I) could add some
>>> stuff to support namespaces and maybe databinding.
>>>
>>> Thanks and regards
>>> Matthias
>>>
>>>
>>>
>>> From:        Shameera Rathnayaka <shameerainfo@gmail.com>
>>> To:        java-user@axis.apache.org,
>>> Date:        26-04-2012 19:40
>>> Subject:        Re: Axis2 - JSON mapped - namespace (mismatch)
>>> ________________________________
>>>
>>>
>>>
>>> Hi Matthias,
>>>
>>> According to the documentation [1] it simply says that “Mapped” formatted
>>> JSON with namespaces are not supported in Axis2, I think you already have
>>> got this point. Let me explain how current implementation of axis2 expect
>>> mapped Json strings.
>>>
>>> The best way to demonstrate this is a short example,
>>> assume you need to send following xml ,
>>>
>>> <price xmlns="http://acme.com">10.00</price>
>>>
>>> Using the mapped convention this can be turned into:
>>>
>>> { "acme.price" : { "10.00" } where http://acme.com --> acme
>>>
>>> as axis2 doesn't support namesapce mapping it expect this as
>>>
>>> { "price" : { "10.00" }
>>> That is why it checks always ':' colon instaed of '.' to get the
>>> localname.
>>>
>>> [1] http://wso2.org/library/768
>>>
>>> Thanks,
>>> Shameera.
>>>
>>>
>>> On Thu, Apr 26, 2012 at 6:29 PM, <gerber@slf.ch> wrote:
>>> Hi
>>>
>>> I'm trying to get my SOAP web service to run using mapped JSON instead of
>>> XML.
>>> Because it is not that obvious when moving to JSON, what works and what
>>> does not, I had to do some drilling down in to the code.
>>> I got a sample Service running based in an
>>> org.apache.axis2.receivers.RawXMLINOutMessageReceiver.
>>> But that's not the way to implement web services in these days.
>>> Basically, as AXIS is designed, we should be able to use databinding, as
>>> soon as we get the JSON stuff properly converted in to XML.
>>> This seams not to be the case at the moment (namespace mismatch)
>>>
>>> So i though about writing a wrapper around my generated skeleton and
>>> adding the correct namespaces myself, based on the prefixes used in the
>>> mapped JSON.
>>>
>>> Now it is where i get confused.
>>> In the documentation is mentioned to us a full stop "." to separate
>>> namespace-pefix from element name.
>>>         http://axis.apache.org/axis2/java/core/docs/json_support.html
>>> When i look at the code, I see, that there a colon ":" is expected to
>>> separate the prefix from the element name.
>>>         See org.apache.axis2.json.AbstractJSONOMBuilder line 116 to 143
>>>
>>> When I use a full stop "." I get an error, that the method is not found
>>> (Axis is looking for the howl thing, prefix and element name)
>>> When I use a colon ":" I get the an error in the data binding (this is ok,
>>>  because of the mismatching namespace issue and when i get the prefixed
>>> matched to the correct namespaces this should be solved.)
>>>
>>> Before I try to work around the mismatching namespace issue I really would
>>> like to know,
>>> how this is supposed to work with prefix, how prefix and element-name are
>>> separated, what prefixes are used for and what axis does with them.
>>>
>>> Thanks for your help and best regards
>>> Matthias
>>>
>>>
>>>
>>> --
>>> Shameera Rathnayaka
>>> Undergraduate
>>> Department of Computer Science and Engineering
>>> University of Moratuwa.
>>> Sri Lanka.
>>>
>>> Blog : http://shameerarathnayaka.blogspot.com/
>>>
>>
>>
>>
>> --
>> Shameera Rathnayaka
>> Undergraduate
>> Department of Computer Science and Engineering
>> University of Moratuwa.
>> Sri Lanka.
>>
>> Blog : http://shameerarathnayaka.blogspot.com/
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Mime
View raw message