You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Enrico Boldrini <bo...@imaa.cnr.it> on 2010/05/21 11:40:36 UTC

Problem with form posting

Dear all,

I've got a runtime exception while sending this message to a CXF 
endpoint binded to a Provider<DataSource>.

POST /gi-cat-7.0.4-SNAPSHOT/services/oaipmh HTTP/1.1
TE: deflate,gzip;q=0.3
Connection: TE, close
From: openarchives@openarchives.org
Host: ade.pin.unifi.it:8080
User-Agent: OAISchemaVal
Content-Length: 13
Content-Type: application/x-www-form-urlencoded
 
key=value

Excerpt from the stacktrace:

Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected 
character 'k' (code 118) in prolog; expected '<'
 at [row,col {unknown-source}]: [1,1]
    at 
com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:648)
    at 
com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2047)

It seems to happen because an XMLMessageInInterceptor intercepts the 
message, although the content type isn't xml.

I am attaching a maven test project wich reproduces the problem.

The JUnit test case passes if using JAXWS-RI for the service (by 
disabling cxf dependencies from the pom).

Let me know if further information is needed, thanks

Enrico

Re: Problem with form posting

Posted by Sho <so...@gmail.com>.
Just wanted to note that the workaround worked for me. Using the below as
specified

<?xml version="1.0"?> 
<notXml>[urlencoded post message here]</notXml>

The only thing to note is that in my case I had to completely reformat my
message into xml with the appropriate namespace specified per the wsdl

--
View this message in context: http://cxf.547215.n5.nabble.com/Problem-with-form-posting-tp562243p5077802.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Problem with form posting

Posted by Enrico Boldrini <bo...@imaa.cnr.it>.
Hello,

for interested people, I found a useful workaround for this problem: 
just write an interceptor that convert from the form post message to a 
xml message and attach it to the RECEIVE phase. you will end up with 
something like:

<?xml version="1.0"?>
<notXml>[urlencoded post message here]</notXml>

that doesn't break the subsequent chain.

Best regards,

Enrico

Daniel Kulp wrote:
> To be completely honest, this isn't really something that is "designed" to 
> work for CXF.    The CXF model really assumes that "root" stuff is completely 
> describable in WSDL and thus would be an XML doc parseable as XML.
>
> If you are going to be doing mostly work with non-xml things, it's strongly 
> suggested that you use the JAX-RS stuff  which is much better aligned for 
> relatively  arbitrary posts and such.
>
> Dan
>
>
> On Friday 21 May 2010 5:40:36 am Enrico Boldrini wrote:
>   
>> Dear all,
>>
>> I've got a runtime exception while sending this message to a CXF
>> endpoint binded to a Provider<DataSource>.
>>
>> POST /gi-cat-7.0.4-SNAPSHOT/services/oaipmh HTTP/1.1
>> TE: deflate,gzip;q=0.3
>> Connection: TE, close
>> From: openarchives@openarchives.org
>> Host: ade.pin.unifi.it:8080
>> User-Agent: OAISchemaVal
>> Content-Length: 13
>> Content-Type: application/x-www-form-urlencoded
>>
>> key=value
>>
>> Excerpt from the stacktrace:
>>
>> Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected
>> character 'k' (code 118) in prolog; expected '<'
>>  at [row,col {unknown-source}]: [1,1]
>>     at
>> com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:648)
>>     at
>> com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:204
>> 7)
>>
>> It seems to happen because an XMLMessageInInterceptor intercepts the
>> message, although the content type isn't xml.
>>
>> I am attaching a maven test project wich reproduces the problem.
>>
>> The JUnit test case passes if using JAXWS-RI for the service (by
>> disabling cxf dependencies from the pom).
>>
>> Let me know if further information is needed, thanks
>>
>> Enrico
>>     
>
>   


Re: Problem with form posting

Posted by Enrico Boldrini <bo...@imaa.cnr.it>.
Dear Dan,

thanks for the clarification. I think that the misunderstanding was born 
by reading the conformance point 1 (An implementation MUST support 
Provider<javax.activation.DataSource> in message mode in conjunction 
with the predefined HTTP binding). So, being DataSource "an abstraction 
of an  arbitrary collection of data providing access to in the form of 
InputStreams and OutputStreams" and being also accustomed to XML 
responses following a HTTP/GET request, I thought also the HTTP/POST 
case (with appropriate content/type) had to be included.

Best regards,

Enrico



Daniel Kulp wrote:
> On Friday 28 May 2010 5:01:24 am Enrico Boldrini wrote:
>   
>> Dear Dan,
>>
>> thank you very much for the response. For this particular case we need
>> both XML messages and generic payload (we have to implement the OAI-PMH
>> specification).
>> It's a bad surprise that CXF doesn't support entirely the JAX-WS
>> specification :-/ (as far I can understand JAX-WS has also support for
>> non-xml message and WSDL supports also mime binding
>> "application/x-www-form-urlencoded").
>>     
>
> Just FYI:  there is nothing in the JAX-WS spec mandating (or even suggesting) 
> any support for non-xml things for the providers.    In fact, section 5.1 of 
> the JAX-WS spec (that talks about the Provider stuff)  specifically says:
>
> "The Provider interface offers an alternative to SEIs and may be implemented 
> by services wishing to work at the XML message level."
>
> If you go further into the spec, Chapter 11 talks about the "HTTP" binding (as 
> apposed to the SOAP binding).    A major point of note is that the spec 
> specifically calls it the XML/HTTP binding to provide "raw XML over HTTP 
> messaging capabilities".
>
> Thus, in this case, CXF is supporting the full JAX-WS spec as written.   I'm 
> not saying what you are trying to do isn't a useful enhancement, but to 
> suggest that CXF doesn't support the full  JAX-WS spec in this case is 
> definitely wrong.
>
> Dan
>
>
>   
>> We really hope that this feature will be supported in the future, as we
>> think CXF has been proved a great implementation so far and we have
>> always appreciated the great work you have put in it!
>>
>> Kind regards,
>>
>> Enrico & the GI-cat team http://zeus.pin.unifi.it/gi-cat
>>
>> Daniel Kulp wrote:
>>     
>>> To be completely honest, this isn't really something that is "designed"
>>> to work for CXF.    The CXF model really assumes that "root" stuff is
>>> completely describable in WSDL and thus would be an XML doc parseable as
>>> XML.
>>>
>>> If you are going to be doing mostly work with non-xml things, it's
>>> strongly suggested that you use the JAX-RS stuff  which is much better
>>> aligned for relatively  arbitrary posts and such.
>>>
>>> Dan
>>>
>>> On Friday 21 May 2010 5:40:36 am Enrico Boldrini wrote:
>>>       
>>>> Dear all,
>>>>
>>>> I've got a runtime exception while sending this message to a CXF
>>>> endpoint binded to a Provider<DataSource>.
>>>>
>>>> POST /gi-cat-7.0.4-SNAPSHOT/services/oaipmh HTTP/1.1
>>>> TE: deflate,gzip;q=0.3
>>>> Connection: TE, close
>>>> From: openarchives@openarchives.org
>>>> Host: ade.pin.unifi.it:8080
>>>> User-Agent: OAISchemaVal
>>>> Content-Length: 13
>>>> Content-Type: application/x-www-form-urlencoded
>>>>
>>>> key=value
>>>>
>>>> Excerpt from the stacktrace:
>>>>
>>>> Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected
>>>> character 'k' (code 118) in prolog; expected '<'
>>>>
>>>>  at [row,col {unknown-source}]: [1,1]
>>>>  
>>>>     at
>>>>
>>>> com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:648
>>>> )
>>>>
>>>>     at
>>>>
>>>> com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:
>>>> 204 7)
>>>>
>>>> It seems to happen because an XMLMessageInInterceptor intercepts the
>>>> message, although the content type isn't xml.
>>>>
>>>> I am attaching a maven test project wich reproduces the problem.
>>>>
>>>> The JUnit test case passes if using JAXWS-RI for the service (by
>>>> disabling cxf dependencies from the pom).
>>>>
>>>> Let me know if further information is needed, thanks
>>>>
>>>> Enrico
>>>>         
>
>   


Re: Problem with form posting

Posted by Daniel Kulp <dk...@apache.org>.
On Friday 28 May 2010 5:01:24 am Enrico Boldrini wrote:
> Dear Dan,
> 
> thank you very much for the response. For this particular case we need
> both XML messages and generic payload (we have to implement the OAI-PMH
> specification).
> It's a bad surprise that CXF doesn't support entirely the JAX-WS
> specification :-/ (as far I can understand JAX-WS has also support for
> non-xml message and WSDL supports also mime binding
> "application/x-www-form-urlencoded").

Just FYI:  there is nothing in the JAX-WS spec mandating (or even suggesting) 
any support for non-xml things for the providers.    In fact, section 5.1 of 
the JAX-WS spec (that talks about the Provider stuff)  specifically says:

"The Provider interface offers an alternative to SEIs and may be implemented 
by services wishing to work at the XML message level."

If you go further into the spec, Chapter 11 talks about the "HTTP" binding (as 
apposed to the SOAP binding).    A major point of note is that the spec 
specifically calls it the XML/HTTP binding to provide "raw XML over HTTP 
messaging capabilities".

Thus, in this case, CXF is supporting the full JAX-WS spec as written.   I'm 
not saying what you are trying to do isn't a useful enhancement, but to 
suggest that CXF doesn't support the full  JAX-WS spec in this case is 
definitely wrong.

Dan


> 
> We really hope that this feature will be supported in the future, as we
> think CXF has been proved a great implementation so far and we have
> always appreciated the great work you have put in it!
> 
> Kind regards,
> 
> Enrico & the GI-cat team http://zeus.pin.unifi.it/gi-cat
> 
> Daniel Kulp wrote:
> > To be completely honest, this isn't really something that is "designed"
> > to work for CXF.    The CXF model really assumes that "root" stuff is
> > completely describable in WSDL and thus would be an XML doc parseable as
> > XML.
> > 
> > If you are going to be doing mostly work with non-xml things, it's
> > strongly suggested that you use the JAX-RS stuff  which is much better
> > aligned for relatively  arbitrary posts and such.
> > 
> > Dan
> > 
> > On Friday 21 May 2010 5:40:36 am Enrico Boldrini wrote:
> >> Dear all,
> >> 
> >> I've got a runtime exception while sending this message to a CXF
> >> endpoint binded to a Provider<DataSource>.
> >> 
> >> POST /gi-cat-7.0.4-SNAPSHOT/services/oaipmh HTTP/1.1
> >> TE: deflate,gzip;q=0.3
> >> Connection: TE, close
> >> From: openarchives@openarchives.org
> >> Host: ade.pin.unifi.it:8080
> >> User-Agent: OAISchemaVal
> >> Content-Length: 13
> >> Content-Type: application/x-www-form-urlencoded
> >> 
> >> key=value
> >> 
> >> Excerpt from the stacktrace:
> >> 
> >> Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected
> >> character 'k' (code 118) in prolog; expected '<'
> >> 
> >>  at [row,col {unknown-source}]: [1,1]
> >>  
> >>     at
> >> 
> >> com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:648
> >> )
> >> 
> >>     at
> >> 
> >> com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:
> >> 204 7)
> >> 
> >> It seems to happen because an XMLMessageInInterceptor intercepts the
> >> message, although the content type isn't xml.
> >> 
> >> I am attaching a maven test project wich reproduces the problem.
> >> 
> >> The JUnit test case passes if using JAXWS-RI for the service (by
> >> disabling cxf dependencies from the pom).
> >> 
> >> Let me know if further information is needed, thanks
> >> 
> >> Enrico

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

Re: Problem with form posting

Posted by Enrico Boldrini <bo...@imaa.cnr.it>.
Dear Dan,

thank you very much for the response. For this particular case we need 
both XML messages and generic payload (we have to implement the OAI-PMH 
specification).
It's a bad surprise that CXF doesn't support entirely the JAX-WS 
specification :-/ (as far I can understand JAX-WS has also support for 
non-xml message and WSDL supports also mime binding 
"application/x-www-form-urlencoded").

We really hope that this feature will be supported in the future, as we 
think CXF has been proved a great implementation so far and we have 
always appreciated the great work you have put in it!

Kind regards,

Enrico & the GI-cat team http://zeus.pin.unifi.it/gi-cat

Daniel Kulp wrote:
> To be completely honest, this isn't really something that is "designed" to 
> work for CXF.    The CXF model really assumes that "root" stuff is completely 
> describable in WSDL and thus would be an XML doc parseable as XML.
>
> If you are going to be doing mostly work with non-xml things, it's strongly 
> suggested that you use the JAX-RS stuff  which is much better aligned for 
> relatively  arbitrary posts and such.
>
> Dan
>
>
> On Friday 21 May 2010 5:40:36 am Enrico Boldrini wrote:
>   
>> Dear all,
>>
>> I've got a runtime exception while sending this message to a CXF
>> endpoint binded to a Provider<DataSource>.
>>
>> POST /gi-cat-7.0.4-SNAPSHOT/services/oaipmh HTTP/1.1
>> TE: deflate,gzip;q=0.3
>> Connection: TE, close
>> From: openarchives@openarchives.org
>> Host: ade.pin.unifi.it:8080
>> User-Agent: OAISchemaVal
>> Content-Length: 13
>> Content-Type: application/x-www-form-urlencoded
>>
>> key=value
>>
>> Excerpt from the stacktrace:
>>
>> Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected
>> character 'k' (code 118) in prolog; expected '<'
>>  at [row,col {unknown-source}]: [1,1]
>>     at
>> com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:648)
>>     at
>> com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:204
>> 7)
>>
>> It seems to happen because an XMLMessageInInterceptor intercepts the
>> message, although the content type isn't xml.
>>
>> I am attaching a maven test project wich reproduces the problem.
>>
>> The JUnit test case passes if using JAXWS-RI for the service (by
>> disabling cxf dependencies from the pom).
>>
>> Let me know if further information is needed, thanks
>>
>> Enrico
>>     
>
>   


Re: Problem with form posting

Posted by Daniel Kulp <dk...@apache.org>.
To be completely honest, this isn't really something that is "designed" to 
work for CXF.    The CXF model really assumes that "root" stuff is completely 
describable in WSDL and thus would be an XML doc parseable as XML.

If you are going to be doing mostly work with non-xml things, it's strongly 
suggested that you use the JAX-RS stuff  which is much better aligned for 
relatively  arbitrary posts and such.

Dan


On Friday 21 May 2010 5:40:36 am Enrico Boldrini wrote:
> Dear all,
> 
> I've got a runtime exception while sending this message to a CXF
> endpoint binded to a Provider<DataSource>.
> 
> POST /gi-cat-7.0.4-SNAPSHOT/services/oaipmh HTTP/1.1
> TE: deflate,gzip;q=0.3
> Connection: TE, close
> From: openarchives@openarchives.org
> Host: ade.pin.unifi.it:8080
> User-Agent: OAISchemaVal
> Content-Length: 13
> Content-Type: application/x-www-form-urlencoded
> 
> key=value
> 
> Excerpt from the stacktrace:
> 
> Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected
> character 'k' (code 118) in prolog; expected '<'
>  at [row,col {unknown-source}]: [1,1]
>     at
> com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:648)
>     at
> com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:204
> 7)
> 
> It seems to happen because an XMLMessageInInterceptor intercepts the
> message, although the content type isn't xml.
> 
> I am attaching a maven test project wich reproduces the problem.
> 
> The JUnit test case passes if using JAXWS-RI for the service (by
> disabling cxf dependencies from the pom).
> 
> Let me know if further information is needed, thanks
> 
> Enrico

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

Re: Problem with form posting

Posted by Enrico Boldrini <bo...@imaa.cnr.it>.
Just a brief add: do you think this is a CXF bug or something is 
missing/wrong in the project?

Any hint is appreciated!

Thanks,
Enrico


Enrico Boldrini wrote:
> Dear all,
>
> I've got a runtime exception while sending this message to a CXF 
> endpoint binded to a Provider<DataSource>.
>
> POST /gi-cat-7.0.4-SNAPSHOT/services/oaipmh HTTP/1.1
> TE: deflate,gzip;q=0.3
> Connection: TE, close
> From: openarchives@openarchives.org
> Host: ade.pin.unifi.it:8080
> User-Agent: OAISchemaVal
> Content-Length: 13
> Content-Type: application/x-www-form-urlencoded
>
> key=value
>
> Excerpt from the stacktrace:
>
> Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected 
> character 'k' (code 118) in prolog; expected '<'
> at [row,col {unknown-source}]: [1,1]
>    at 
> com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:648)
>    at 
> com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2047) 
>
>
> It seems to happen because an XMLMessageInInterceptor intercepts the 
> message, although the content type isn't xml.
>
> I am attaching a maven test project wich reproduces the problem.
>
> The JUnit test case passes if using JAXWS-RI for the service (by 
> disabling cxf dependencies from the pom).
>
> Let me know if further information is needed, thanks
>
> Enrico