You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by kkwang <ka...@gmail.com> on 2011/06/27 03:53:21 UTC

Can't Process HTTP request sent by XMLHttpRequest

Hi all,

I have a CXF-based soap service running on tomcat. I'm trying to invoke its
service methods from a web page by using XMLHttpRequest. I construct the
soap request xml and pass the xml string to XMLHttpRequest.send() method.
For example:

var xml = '<soapenv:Envelope xmlns:app="http://ws.ebizcard.com/app"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">' +
   					 
'<soapenv:Body><app:AuthenticateUserType><app:LoginCredential><app:UserEmail>test@gmail.com</app:UserEmail>'
+ 
            		 
'<app:Password>test</app:Password></app:LoginCredential></app:AuthenticateUserType></soapenv:Body></soapenv:Envelope>';

xmlhttp.send(xml);

However, the back-end service blows up with this error message:

Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
 at [row,col {unknown-source}]: [1,0]
	at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:686)
	at com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2134)
	at
com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2040)
	at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1069)
	at com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1095)
	at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:122)

I use Fiddler to capture http traffic and see what's wrong. The http request
body doesn't seem to contain anything. However, if I construct a raw http
request in Fiddler and just paste the same xml in the request body,
everything works fine. Anyone has any idea?

Thanks
Kang

--
View this message in context: http://cxf.547215.n5.nabble.com/Can-t-Process-HTTP-request-sent-by-XMLHttpRequest-tp4526853p4526853.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Can't Process HTTP request sent by XMLHttpRequest

Posted by Benson Margulies <bi...@gmail.com>.
You can also read the javascript client support code in CXF to see how
to do this.

On Thu, Jun 30, 2011 at 1:19 PM, Aki Yoshida <el...@googlemail.com> wrote:
> Hi,
> as you already described, your xmlhttp instance is not posting a
> proper soap message to the cxf service.
> I suppose you are not setting up your xmlhttp instance appropriately
> for posting a soap message. You can look into the XMLHttpRequest
> documentation.
> regards, aki
>
> 2011/6/27 kkwang <ka...@gmail.com>:
>> Hi all,
>>
>> I have a CXF-based soap service running on tomcat. I'm trying to invoke its
>> service methods from a web page by using XMLHttpRequest. I construct the
>> soap request xml and pass the xml string to XMLHttpRequest.send() method.
>> For example:
>>
>> var xml = '<soapenv:Envelope xmlns:app="http://ws.ebizcard.com/app"
>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">' +
>>
>> '<soapenv:Body><app:AuthenticateUserType><app:LoginCredential><app:UserEmail>test@gmail.com</app:UserEmail>'
>> +
>>
>> '<app:Password>test</app:Password></app:LoginCredential></app:AuthenticateUserType></soapenv:Body></soapenv:Envelope>';
>>
>> xmlhttp.send(xml);
>>
>> However, the back-end service blows up with this error message:
>>
>> Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
>>  at [row,col {unknown-source}]: [1,0]
>>        at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:686)
>>        at com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2134)
>>        at
>> com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2040)
>>        at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1069)
>>        at com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1095)
>>        at
>> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:122)
>>
>> I use Fiddler to capture http traffic and see what's wrong. The http request
>> body doesn't seem to contain anything. However, if I construct a raw http
>> request in Fiddler and just paste the same xml in the request body,
>> everything works fine. Anyone has any idea?
>>
>> Thanks
>> Kang
>>
>> --
>> View this message in context: http://cxf.547215.n5.nabble.com/Can-t-Process-HTTP-request-sent-by-XMLHttpRequest-tp4526853p4526853.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>>
>

Re: Can't Process HTTP request sent by XMLHttpRequest

Posted by kkwang <ka...@gmail.com>.
Actually, I just found out why this error is happening. It turns out that
Firefox pre-flights the POST request with an OPTIONS request, which contains
no request body. My cxf service doesn't handle the OPTIONS request and tries
to read and parse the soap message, which doesn't get passed. I can get
around this by not setting and request headers to prevent the pre-flight.
See this https://developer.mozilla.org/en/HTTP_access_control

--
View this message in context: http://cxf.547215.n5.nabble.com/Can-t-Process-HTTP-request-sent-by-XMLHttpRequest-tp4526853p4539572.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Can't Process HTTP request sent by XMLHttpRequest

Posted by Aki Yoshida <el...@googlemail.com>.
Hi,
as you already described, your xmlhttp instance is not posting a
proper soap message to the cxf service.
I suppose you are not setting up your xmlhttp instance appropriately
for posting a soap message. You can look into the XMLHttpRequest
documentation.
regards, aki

2011/6/27 kkwang <ka...@gmail.com>:
> Hi all,
>
> I have a CXF-based soap service running on tomcat. I'm trying to invoke its
> service methods from a web page by using XMLHttpRequest. I construct the
> soap request xml and pass the xml string to XMLHttpRequest.send() method.
> For example:
>
> var xml = '<soapenv:Envelope xmlns:app="http://ws.ebizcard.com/app"
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">' +
>
> '<soapenv:Body><app:AuthenticateUserType><app:LoginCredential><app:UserEmail>test@gmail.com</app:UserEmail>'
> +
>
> '<app:Password>test</app:Password></app:LoginCredential></app:AuthenticateUserType></soapenv:Body></soapenv:Envelope>';
>
> xmlhttp.send(xml);
>
> However, the back-end service blows up with this error message:
>
> Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
>  at [row,col {unknown-source}]: [1,0]
>        at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:686)
>        at com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2134)
>        at
> com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2040)
>        at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1069)
>        at com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1095)
>        at
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:122)
>
> I use Fiddler to capture http traffic and see what's wrong. The http request
> body doesn't seem to contain anything. However, if I construct a raw http
> request in Fiddler and just paste the same xml in the request body,
> everything works fine. Anyone has any idea?
>
> Thanks
> Kang
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Can-t-Process-HTTP-request-sent-by-XMLHttpRequest-tp4526853p4526853.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>