You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by feng <f....@gmail.com> on 2012/03/18 18:35:05 UTC

help generated javascript client not sending request properly

Dear all,

I have an soap web service deployed on apache axis2c engine. The services
fully tested with soapui. Now, I just use apache cxf generated the
javascript client code and put on a web site. But no matter what I tried,
the XMLHttprequest in the cxf-utils.js doesn't sending out the request. 
I have used the wireshark to decode the http request content and find out
the javascript client doesn't include the soap envelop in the http request. 
Not sure if I missed some configuration somewhere, anyone can provide me a
clue to solve the problem? Thanks a lot.

Feng

--
View this message in context: http://cxf.547215.n5.nabble.com/help-generated-javascript-client-not-sending-request-properly-tp5575360p5575360.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: help generated javascript client not sending request properly

Posted by feng <f....@gmail.com>.
Finally, I find out why.
In case anyone interested or having the same problem. It is caused by cross
site scripting issue. Instead of POST request being sent, the XMLHttpRequest
is sending out an OPTION request. 
Fixed by modifying the url without domain name. e.g.
http://localhost:8080/axis2/services/Alm to /axis2/services/Alm. 
The generated js code works fine as well.


--
View this message in context: http://cxf.547215.n5.nabble.com/help-generated-javascript-client-not-sending-request-properly-tp5575360p5577507.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: help generated javascript client not sending request properly

Posted by feng <f....@gmail.com>.
Providing more detail, I have debugged in the javascript file. And I tried to
send a soap envelope with the following javascript code, also pasted axis2c
log bellow.

================================================================================
try {
	var soapXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soap-env:Envelope
xmlns:soap-env=\"http:\/\/schemas.xmlsoap.org/soap/envelope/\"
xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soap-env:Body
xmlns:jns0='http://uk.ac.ed.maths.org/xsd'
xmlns:jns1='http://uk.ac.ed.maths.org' ><jns1:optimizePortfolioSSD
xmlns:jns0='http://uk.ac.ed.maths.org/xsd'
xmlns:jns1='http://uk.ac.ed.maths.org' ><jns1:args0
xmlns:jns0='http://uk.ac.ed.maths.org/xsd'
><jns0:symbols>GOOG</jns0:symbols><jns0:symbols>AAPL</jns0:symbols><jns0:symbols>MSFT</jns0:symbols></jns1:args0><jns1:args1>INDEX</jns1:args1><jns1:args2>2012-02-01T00:00:00</jns1:args2><jns1:args3>2012-03-01T00:00:00</jns1:args3></jns1:optimizePortfolioSSD></soap-env:Body></soap-env:Envelope>";
	var req = new XMLHttpRequest();
	req.open("POST","http://localhost:8080/axis2/services/Alm",true);
	req.onreadystatechange = alert(req.readyState);
	req.setRequestHeader("MessageType", "CALL");
	req.setRequestHeader("Content-Type", "text/xml");
	req.setRequestHeader("Content-Length", soapXml.length);
	req.setRequestHeader("SOAPAction","urn:optimizePortfolioSSD");
	req.send(soapXml);
	}
	catch(ex)
	{
		throw ex;
	}
================================================================
Axis2c log

[Sun Mar 18 19:09:18 2012] [debug] apache2_worker.c(238)
http://localhost:8080/axis2/services/Alm
[Sun Mar 18 19:09:18 2012] [debug] apache2_worker.c(280) Client HTTP version
HTTP/1.1
=============================================================
wireshark tcp stream for the request

OPTIONS /axis2/services/Alm HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:11.0) Gecko/20100101
Firefox/11.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Origin: http://172.20.104.190
Access-Control-Request-Method: POST
Access-Control-Request-Headers: content-type,messagetype,soapaction
Pragma: no-cache
Cache-Control: no-cache

HTTP/1.1 501 Method Not Implemented
Date: Sun, 18 Mar 2012 19:16:49 GMT
Server: Apache/2.2.20 (Ubuntu)
Content-Length: 158
Connection: close
Content-Type: text/html

<html><head><title>501 Not Implemented</title></head><body>
Not Implemented
<p>The requested Method is notimplemented on this server.</p></body></html>
=================================================================
Thanks for anyone can provide a comment or hints. 

--
View this message in context: http://cxf.547215.n5.nabble.com/help-generated-javascript-client-not-sending-request-properly-tp5575360p5575517.html
Sent from the cxf-user mailing list archive at Nabble.com.