Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with Simple soap request from javascript to my local server

Status
Not open for further replies.

ne1b

Programmer
Mar 12, 2011
2
US
server GlassFish3 with in NetBeans

What is missing on the following script:
Any help will be appreciated. I kind of stack on this.
<html>
<head>
</head>
<body>
<a onclick="sendSoap()" href="#">testC</a>
<script type="text/javascript" language=javascript>
function sendSoap()
{
var xmlhttp = new XMLHttpRequest();
var url = " var soap = "<?xml version='1.0' encoding='utf-8'?>"+
"<S:Envelope xmlns:S=' "<S:Header/><S:Body><ns2:sayHello xmlns:ns2=' "<arg0>test Hello</arg0></ns2:sayHello></S:Body></S:Envelope>";
//alert(soap);
xmlhttp.open("POST", url, true);
//xmlhttp.setRequestHeader("SOAPAction", " //xmlhttp.setRequestHeader("Content-Type", "text/xml");
xmlhttp.send(soap);
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState == 4)
{
var resultText = xmlhttp.responseText;
alert(resultText);
}
}
}
</script>
</body>
</html>

here is how th SOAP request and response should look like:
SOAP Request

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S=" <S:Header/>
<S:Body>
<ns2:sayHello xmlns:ns2=" <arg0>test Hello</arg0>
</ns2:sayHello>
</S:Body>
</S:Envelope>

SOAP Response

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S=" <S:Body>
<ns2:sayHelloResponse xmlns:ns2=" <return>Hello test Hello!</return>
</ns2:sayHelloResponse>
</S:Body>
</S:Envelope>
 
So where's the problem right now?

Cheers,
Dian
 
The problem was there was no response. no fault or success. but now I found out that I cant access the server from my local page unless I write this page on the server side page like .jsp

But now the other question is, what should I do if I don't have an access to the server providing a web service and if I want to consume a web service on my page?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top