Javascript SOAP Request, Return String - javascript

What I'm attempting seems relatively simple, but I can't seem to find a simple answer on how to do it. I have a WCF Web Service that is self hosted. It has one function that accepts zero parameters and returns a string. All I want to do is request that method from javascript and capture that string response in javascript
Here is the code I have, and so far it won't even return anything. I can get requests easily if I use something like SOAPUI.
App.Config
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="test.XKORE.MobileDeviceServices.Properties.Settings.ConnectionString"
connectionString="Data Source=tester;Initial Catalog=test;User ID=testc;Password=testp" />
</connectionStrings>
<system.web>
<compilation debug="true"/>
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="test.XKORE.MobileDeviceServices.XKOREMobileService" behaviorConfiguration="XKOREMobileServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8523/test/XKORE/XKOREMobileService" />
</baseAddresses>
</host>
<endpoint address="" binding="basicHttpBinding" contract="test.XKORE.MobileDeviceServices.IXKOREMobileService" bindingNamespace="http://test.XKORE.MobileDeviceServices" />
<endpoint address="mex" binding="mexHttpBinding" contract="test.XKORE.MobileDeviceServices.IXKOREMobileService" bindingNamespace="http://test.XKORE.MobileDeviceServices" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="XKOREMobileServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
Interface
[ServiceContract]
public interface IXKOREMobileService
{
[OperationContract]
string GetChartData();
// TODO: Add your service operations here
}
SOAP Request
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/IXKOREMobileService/GetChartData</Action>
</s:Header>
<s:Body>
<GetChartData xmlns="http://tempuri.org/" />
</s:Body>
</s:Envelope>
Javascript (Not Working)
var response = BuildSOAPMessage('GetChartData');
alert(response);
function BuildSOAPMessage (func) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "http://localhost:8523/test/XKORE/XKOREMobileService", true);
var msg = '';
msg += '<?xml version="1.0" encoding="utf-8"?>'
msg += '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">'
msg += '<soapenv:Header/>'
msg += '<soapenv:Body>'
msg += '<tem:' + func + '/>'
msg += '</soapenv:Body>'
msg += '</soapenv:Envelope>'
alert (msg);
// Send the POST request
xmlhttp.setRequestHeader('Content-Type', 'text/xml');
xmlhttp.setRequestHeader("SOAPAction", "http://tempuri.org/IXKOREMobileService/GetJSONChartData");
xmlhttp.send(msg);
return xmlhttp.responseXML;
}

There are a couple of issues in your code:
You specified that the XmlHttpRequest object will be asynchronous (passing true in the third parameter to the open call). That means you don't get the results after calling send, you need to wait for the event to access the responseXML property.
It's very likely that you're hitting a cross-domain restriction. XMLHttpRequest cannot, by default, send requests to sites other than the one where the page arrived. You're self-hosting the WCF service, and I'm assuming that the page which hosts the JavaScript code is coming from some other domain. That will be blocked by the browser.

Closing this thread and opening a separate one since the issue is more related to cross domain problems.

Related

Passing a url with search parameters to an android app

I am making an android app and doing pretty well atm. What I want is when a user presses a url with variable search parameters attached to it, that the entire url is sent to my app.
The app opens well, but I don't know how to get the search parameters in there as well.
Btw. the app has a webview of the internet page in it, which works fine. I am opening the app itself as well as clicking on the links sent to whatsapp and messenger from within my app.
E.g. the url could be https://www.sendamap.com/index.php?g=100&z=200
Standard the https://www.sendamap.com is opened. I would like the whole url to be passed to the app.
In android studio I am struggling with the following in the MainActivity;
Intent intent = getIntent();
Uri data = intent.getData();
String url = data.toString();
webView.loadUrl(url);
Okay, it works now. It was mainly in my code (duh).
AndroidManifest.xml; "https" is important (besides everything else).
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https"
android:host="www.sendamap.com" />
</intent-filter>
MainActivity.java; "this." was added before "getIntent().getData().
Uri uri = this.getIntent().getData();
if (uri != null) {
url = uri.toString();
}
webView.loadUrl(url);

Error 400 when calling WCF JSONP web service method

I've created a WCF service that I'm attempting to use for a cross-domain call (using jQuery and JSONP). I've written the service and when I run it in the Visual Studio debugger and call it from a test page on my local PC it works fine. When I deploy the service to IIS7 on our server, it doesn't work. Looking at it with Fiddler, I see there's a 400 error coming back.
This is my first attempt at creating a WCF service and also my first attempt at JSONP, so it is highly possible I've missed something simple yet important.
I have 2 methods on this service, one really simple one (called GetData) which just takes a string and returns it - I created this one just to test the basic service functionality (i.e. I can just put the URL into a browser and I get some json back) and it works OK.
The other, problematic, one (called GetMatter) takes a couple of parameters, calls another (SOAP) web service to get some data and returns a Stream containing the call to my callback function. This then gets inserted into the calling page which displays the result.
The contract looks like this:
[ServiceContract]
public interface IOracleService
{
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "getData/{value}")]
string GetData(string value);
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "getMatter/{matterId}/{callback}")]
Stream GetMatter(string matterId, string callback);
}
The implementation looks like this:
public class OracleService : IOracleService
{
public string GetData(string value)
{
return string.Format("You entered: {0}", value);
}
public Stream GetMatter(string matterId, string callback)
{
//call web service
var serviceResult = <call to web service goes here>;
//serialize data to json
JavaScriptSerializer js = new JavaScriptSerializer();
string jsonResult = js.Serialize(serviceResult.data);
jsonResult = jsonResult.Substring(1, jsonResult.Length - 2);
string result = callback + "(" + jsonResult + ");";
return new MemoryStream(Encoding.UTF8.GetBytes(result));
}
}
My simple Test.html page looks like this (for the purposes of this test, the js file is just stored on my local Q: drive):
<html>
<head>
<script src="./jquery-2.2.2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="output"></div>
<div id="output2"></div>
<script language="javascript">
var url = "Q:\TestService.js";
var script = document.createElement("script");
script.setAttribute("src", url);
script.setAttribute("type", "text/javascript");
document.body.appendChild(script);
</script>
</body>
</html>
TestService.js is as follows (note that Service.Legal is the namespace that OracleService is defined in, and MyServer is the name of the server that I've deployed the service to. When running in the debugger, MyServer is changed to "localhost:portnumber" and this works OK then)
var url = "http://MyServer/Service.Legal.OracleWebService/OracleService.svc/GetData/1";
url += "?" + new Date().getTime().toString(); //append time to prevent caching
var script = document.createElement("script");
script.setAttribute("src", url);
script.setAttribute("type", "text/javascript");
document.body.appendChild(script);
function ServiceCallback(data) {
console.log("got data: ");
console.dir(data);
var result = data;
var date = new Date(parseInt(result.INVOICE_DATE.substr(6)));
var output = "<ul>";
output += "<li>INVOICE DATE: " + date + "</li>";
output += "<li>TOTAL EXCL GST: " + result.TOTAL_EXCL_GST + "</li>";
output += "<li>FEE ESTIMATE: " + result.FEE_ESTIMATE + "</li>";
output += "</ul>";
$("#output").html(output);
}
Finally, the web.config looks like:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Windows" />
</system.web>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webHttpBinding" crossDomainScriptAccessEnabled="true">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
<client />
<services>
<service name="Service.Legal.OracleWebService.OracleService">
<endpoint address="" binding="webHttpBinding" contract="Service.Legal.OracleWebService.IOracleService" behaviorConfiguration="webBehaviour" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://MyServer/Service.Legal.OracleWebService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehaviour">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type, Accept" />
</customHeaders>
</httpProtocol>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
<httpErrors errorMode="Detailed" />
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
</configuration>
As I said above, when I run this service in the Visual Studio debugger, my html page runs the javascript in TestService.js, the javascript calls my service (http://localhost:15021/OracleService.svc/GetMatter/matterId/ServiceCallback) and I end up with the expected data being displayed on the page.
When I change that service url to point at the server (http://MyServer/Service.Legal.OracleWebService/OracleService.svc/GetMatter/matterId/ServiceCallback), I get a blank page and Fiddler shows the request giving error 400.
A basic test of the web service directly in the browser
http://MyServer/Service.Legal.OracleWebService/OracleService.svc/getData/1
does return the expected json data (although obviously IE just asks if I want to open or save "1.json", it doesn't display anything in the browser), so the service itself does appear to be accessible and working OK in IIS. There just seems to be something wrong with my GetMatter function or the way I'm calling it that is preventing it from working on the server.
Hmm OK never mind, I think I was looking at the wrong problem.
The 400 (bad request) error made me think the problem was with the call to my web service. But it seems the problem is actually happening on the server side when my web service tries to call the other web service. When I took out that call to the other web service, my service returned a 200 (success) instead. I'm going to work on the assumption that what I've got (as posted above) is OK, and the issue is something to do with the call to the other web service. Perhaps a firewall issue that is preventing the call going from my server to that server, while allowing it to go from my development machine to the same server.

How to getelementbytagname from specific asp.net web service

Please, I'm stuck in a little problem using getElementsByTagName command on a js file with a PhoneGap project. I'm consuming a asp.net web service that works perfectly, but I failed to get the result that the web service is returning me, and that is string from <IngresarRegistroMovilResult> tag.
This is my function that receives the web service return:
function processResult() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
var theXML = xmlhttp.responseXML.documentElement;
var resultadoWebService = theXML.getElementsByTagName('string')[0].firstChild.nodeValue;
var output = "Resultado: ";
output += resultadoWebService;
console.log("Pasamos por processResult, con var output:"+output);
document.getElementById("resultadows").innerHTML = output;
}
};
This is the specification of the web service:
POST /servicio.asmx HTTP/1.1
Host: dondeestamifamilia.masterdevelopment.co
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<IngresarRegistroMovil xmlns="http://dondeestamifamilia.masterdevelopment.co/">
<hashString>string</hashString>
</IngresarRegistroMovil>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<IngresarRegistroMovilResponse xmlns="http://dondeestamifamilia.masterdevelopment.co/">
<IngresarRegistroMovilResult>string</IngresarRegistroMovilResult>
</IngresarRegistroMovilResponse>
</soap12:Body>
</soap12:Envelope>
This is the fragment corresponding to IngresarRegistroMovil method, from the wsdl:
<s:element name="IngresarRegistroMovil">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="hashString" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="IngresarRegistroMovilResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="IngresarRegistroMovilResult" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
I've tried theXML.getElementsByTagName('string')[0].firstChild.nodeValue;
but I get: Uncaught TypeError: Cannot read property 'firstChild' of undefined. theXML.getElementsByTagName('string')[0]; but I get: undefined. theXML.getElementsByTagName('string')[0].nodeValue; but I get: Uncaught TypeError: Cannot read property 'nodeValue' of undefined.
Please, your great support will be extremely valuable to me.
Thanks.
The tagname is IngresarRegistroMovilResult not string which you can acces by theXML.getElementsByTagName('IngresarRegistroMovilResult')[0].textContent (if I made no typo)
The result of consuming the web service has the value of the return variable from the web service. In other words, theXML.innerHTML contains C----O, that is the string value of IngresarRegistroMovilResult, flat, without tags. The error I was getting, then, is for trying to get the return value through a tagname.

How can I send a SOAP request and receive a response using HTML?

I would like to send a number to a SOAP "server"(I don't know if I can call it a server, correct me if I'm wrong) and receive a response using HTML, I've seen many questions with answers containing examples of sending an XML request such as below, but I have no idea on how to receive and see a response on HTML, sorry I'm new to SOAP.
P.S.: Of course, by HTML I meant JavaScript within the HTML :P
Server: Here
Thanks in Advance!
<html>
<head>
<title>SOAP JavaScript Client Test</title>
<script type="text/javascript">
function soap() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('POST', 'http://192.168.0.251:9080/wsa/wsa1', true);
// build SOAP request
var sr =
'<?xml version="1.0" encoding="utf-8"?>' +
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:services-progress-com:notavailable">' +
'<soapenv:Header/>' +
'<soapenv:Body>' +
'<urn:lnestagio>' +
'<urn:vvalor>5</urn:vvalor>' +
'</urn:lnestagio>' +
'</soapenv:Body>' +
'</soapenv:Envelope>';
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
alert('done use firebug to see response');
}
}
}
// Send the POST request
xmlhttp.setRequestHeader('Content-Type', 'text/xml');
xmlhttp.send(sr);
// send request
// ...
}
</script>
</head>
<body>
<form name="Demo" action="" method="post">
<div>
<input type="button" value="Soap" onclick="soap();" />
</div>
</form>
</body>
<html>
SOAP's XML from my server
<wsdl:definitions xmlns:tns="urn:services-progress-com:ys:server" xmlns:S2="urn:services-progress-com:sys:server:Estagio" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:prodata="urn:schemas-progress-com:xml-prodata:0001" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:S1="urn:soap-fault:details" xmlns="http://schemas.xmlsoap.org/wsdl/" name="Estagio" targetNamespace="urn:services-progress-com:sys:server">
<wsdl:documentation>
Author=sys, EncodingType=DOC_LITERAL, WSA_Product=10.2B07 - N/A
</wsdl:documentation>
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" targetNamespace="urn:soap-fault:details">
<element name="FaultDetail">
<complexType>
<sequence>
<element name="errorMessage" type="xsd:string"/>
<element name="requestID" type="xsd:string"/>
</sequence>
</complexType>
</element>
</schema>
<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="urn:services-progress-com:sys:server:Estagio">
<element name="lnestagio">
<complexType>
<sequence>
<element name="vvalor" nillable="true" type="xsd:decimal"/> <!-- Here I think he gets the number I sent -->
</sequence>
</complexType>
</element>
<element name="lnestagioResponse">
<complexType>
<sequence>
<element name="result" nillable="true" type="xsd:string"/>
<element name="vcalc" nillable="true" type="xsd:decimal"/> <!-- And it returns the number multiplied by 2 -->
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<wsdl:message name="FaultDetailMessage">
<wsdl:part name="FaultDetail" element="S1:FaultDetail"/>
</wsdl:message>
<wsdl:message name="Estagio_lnestagio">
<wsdl:part name="parameters" element="S2:lnestagio"/>
</wsdl:message>
<wsdl:message name="Estagio_lnestagioResponse">
<wsdl:part name="parameters" element="S2:lnestagioResponse"/>
</wsdl:message>
<wsdl:portType name="EstagioObj">
<wsdl:operation name="lnestagio">
<wsdl:input message="tns:Estagio_lnestagio"/>
<wsdl:output message="tns:Estagio_lnestagioResponse"/>
<wsdl:fault name="EstagioFault" message="tns:FaultDetailMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="EstagioObj" type="tns:EstagioObj">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="lnestagio">
<soap:operation soapAction="" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="EstagioFault">
<soap:fault name="EstagioFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="EstagioService">
<wsdl:port name="EstagioObj" binding="tns:EstagioObj">
<wsdl:documentation/>
<soap:address location="http://localhost:9080/wsa/wsa1"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Well, a SOAP server is designed to receive SOAP requests and send SOAP responses.
Since SOAP is basically XML, instead of expecting an HTML response from the server, it would be more appropriate to look for a mean to parse the XML of the SOAP response and display it in HTML.
But as I'm typing this answer, I think you may have misunderstood the goal of a SOAP server. It seems to me that you want to display the raw SOAP response directly to the client browser. But a SOAP server is not intended to work that way.
Typically a SOAP server is used by another server, by doing a SOAP request to it and then parsing the SOAP response. And this "other server" may be, for example, an HTTP server.
Let's take an example. I want to know the weather forecast of my city for tomorrow. I go to dummyweatherforecast.com and type the name of my city in the search field. But dummyweatherforecast.com does not store all the weather forecasts by itself. It may instead contact a SOAP server (specifically designed to provide weather forecasts) with a SOAP request containing the name of my city. The SOAP server returns a SOAP response with different weather information (sunny/cloudy, temperature, etc.) and then dummyweatherforecast.com processes this SOAP response (that is, as a reminder, XML) to display it to the client with a beautiful sentence like "It will be sunny tomorrow, with 86°F. Take your swimsuit !" ornamented with a beautiful sun iconography.
As you see, the client doesn't even know that a SOAP communication is held between dummyweatherforecast.com and the SOAP server. And this how SOAP is used : by servers themselves, and rarely directly by clients. This is what we call "web services", even though this term refers to a more general set of technologies used to make computers talk to each others.
I hope this brightened your mind a little bit.
PS : by the way, the link you give for your server points to an IP not available publicly (192.168 adresses are for private networks).

Calling WCF service from Javascript over HTTPS results in Access Denied

I wrote a WCF service that returns a JSON response. I then created an html page with some JavaScript code to test the function. When I published the service to the staging environment (which uses SSL to emulate the production environtment), I had to update the web.config file of my service to work over HTTPS. All seems ok when I browse directly to the .svc endpoint (the service page displays in both http and https) and when I call the service in a browser (I am prompted to download the JSON response) however when I change my test page to point to the https version, I get an 'Access Denied' error.
Here is the code for the servicemodel section of my config file:
<system.serviceModel>
<services>
<service name="Services.PromotionCodeGeneration" behaviorConfiguration="md">
<endpoint address="" binding="webHttpBinding" contract="Services.IPromotionCodeGeneration" behaviorConfiguration="webHttp" bindingConfiguration="webBindingSecure"/>
<endpoint address="" binding="webHttpBinding" contract="Services.IPromotionCodeGeneration" behaviorConfiguration="webHttp" bindingConfiguration="webBinding"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="md">
<serviceMetadata httpsGetEnabled="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webHttp">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="webBindingSecure">
<security mode="Transport"/>
</binding>
<binding name="webBinding">
<security mode="None"></security>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
Here is the code from my test page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title></title>
<script>
function api_test() {
var url = "https://test.mydomain.com/Services/PromotionCodeGeneration.svc/contest/useremail#mydomain.com";
var client = new XMLHttpRequest();
client.open("GET", url, false);
client.setRequestHeader("Authentication-Key", "LK589-JIJO-SHG9-0987-65TG-HJKU-Y$GH");
client.send();
var responseText = client.responseText;
var result = JSON.parse(responseText);
document.writeln("Id: " + result.Id + "<br/>");
document.writeln("Code: " + result.Code + "<br/>");
var expiryDate = "";
if (result.Expires != null){expiryDate = result.Expires;}
document.writeln("Expires: " + expiryDate + "<br/>");
document.writeln("Status: " + result.Status + "<br/>");
}
</script>
</head>
<body onload="api_test();">
</body>
</html>
I have been researching the problem for 2 days. I find alot of people saying you can't use the 'XMLHttpRequest' method across domains but it works find for me over basic http so I find that hard to believe. I have also tried MANY different servicemodel configuration suggestions however none worked for the https communication. Does anyone see anyything in my config or calling page that is causing the 'Access Denied' response over https?
Any help would be appreciated.
Do the HTML page and the service conform to the Same Origin Policy?
The domain name must be the same, including subdomains (so you couldn't, for example, load a file hosted on test1.example.com in a page on test2.example.com).
The protocol (e.g. http or https) must be the same.
The port must be the same (for example, you can't load a file at example.com:8080 from a page at example.com).
All AJAX requests need to meet this policy - otherwise, as #Mike Miller suggested, you may need to look at JSONP.

Categories