1

I am developing hybrid app i want to make my app dynamic.so i have data url as xml format.but when i tried to get the data it is failed.so please help me to solve the problem.

 <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    </head>
    <body>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
var allowCrossDomain = function(req, res, next) {
  // Website you wish to allow to connect
  res.setHeader('Access-Control-Allow-Origin', 'http://localhost');

  // Request methods you wish to allow
 res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');

  // Request headers you wish to allow
  res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');

  // Set to true if you need the website to include cookies in the requests sent
  // to the API (e.g. in case you use sessions)
  res.setHeader('Access-Control-Allow-Credentials', true);

  // Pass to next layer of middleware
  next();
};

    var webServiceURL = 'http://wetexmobapp.ourdemopage.com/webService/getFloorPlanAll.asmx/getWebsite_FloorPlanAll';
    var soapMessage = '<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><GetAllCategoryFamilies xmlns="http://tempuri.org/" /></soap12:Body></soap12:Envelope';

    function CallService()
    {
        $.ajax({
    url: webServiceURL, 
    type: "POST",
    dataType: "xml", 
    data: soapMessage, 
    processData: false,
    contentType: "text/xml; charset=\"utf-8\"",
    success: OnSuccess, 
    error: OnError
});

        return false;
    }

    function OnSuccess(data, status)
    {
        alert(data.d);
    }

    function OnError(request, status, error)
    {
        alert('error');
    }

    $(document).ready(function() {
        jQuery.support.cors = true;
    });
</script>

<form method="post" action="">
    <div>
        <input type="button" value="Call Web Service" onclick="CallService(); return false;" />
    </div>
</form>

</body>
</html>

getFloorPlanAll

Click here for a complete list of operations.
getWebsite_FloorPlanAll

Test
To test the operation using the HTTP POST protocol, click the 'Invoke' button.

SOAP 1.1

The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.

POST /webService/getFloorPlanAll.asmx HTTP/1.1
Host: wetexmobapp.ourdemopage.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://app.wetex.ae/getWebsite_FloorPlanAll"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <getWebsite_FloorPlanAll xmlns="http://app.wetex.ae/" />
  </soap:Body>
</soap:Envelope>

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <getWebsite_FloorPlanAllResponse xmlns="http://app.wetex.ae/">
      <getWebsite_FloorPlanAllResult>xml</getWebsite_FloorPlanAllResult>
    </getWebsite_FloorPlanAllResponse>
  </soap:Body>
</soap:Envelope>

SOAP 1.2

The following is a sample SOAP 1.2 request and response. The placeholders shown need to be replaced with actual values.

POST /webService/getFloorPlanAll.asmx HTTP/1.1
Host: wetexmobapp.ourdemopage.com
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>
    <getWebsite_FloorPlanAll xmlns="http://app.wetex.ae/" />
  </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>
    <getWebsite_FloorPlanAllResponse xmlns="http://app.wetex.ae/">
      <getWebsite_FloorPlanAllResult>xml</getWebsite_FloorPlanAllResult>
    </getWebsite_FloorPlanAllResponse>
  </soap12:Body>
</soap12:Envelope>

HTTP GET

The following is a sample HTTP GET request and response. The placeholders shown need to be replaced with actual values.

GET /webService/getFloorPlanAll.asmx/getWebsite_FloorPlanAll? HTTP/1.1
Host: wetexmobapp.ourdemopage.com

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0"?>
xml

HTTP POST

The following is a sample HTTP POST request and response. The placeholders shown need to be replaced with actual values.

POST /webService/getFloorPlanAll.asmx/getWebsite_FloorPlanAll HTTP/1.1
Host: wetexmobapp.ourdemopage.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0"?>
xml

invoked data inside

<DocumentElement><FloorPlan><Id>1</Id><FloorPlan_Url>http://wetexmobapp.ourdemopage.com/uploads/documents/floorPlan/WETEX-Floorplan-2016-07-13.pdf</FloorPlan_Url><PublishedDateTime>7/11/2016 12:00:00 AM</PublishedDateTime><CreatedDatetime>7/13/2016 5:34:00 AM</CreatedDatetime><Status>Active</Status></FloorPlan></DocumentElement>

this is the error statement

Using //@ to indicate sourceMappingURL pragmas is deprecated. Use //# instead jquery.min.js:1:0 The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. text.html Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://wetexmobapp.ourdemopage.com/webService/getFloorPlanAll.asmx/getWebsite_FloorPlanAll. (Reason: CORS header 'Access-Control-Allow-Origin' missing).

i tried many steps to solve Access-Control-Allow-Origin problem but still showing same problem.

Nidhin Johny
  • 175
  • 3
  • 17
  • Are you requesting the ajax call from this `http://wetexmobapp.ourdemopage.com/` domain or different. – The_ehT Aug 04 '16 at 06:16
  • ya. we already have xml data in this link i want to take data from this link – Nidhin Johny Aug 04 '16 at 06:46
  • I mean the html code you are showing here are they at `http://wetexmobapp.ourdemopage.com/`? – The_ehT Aug 04 '16 at 07:08
  • no it is saved in my system.the xml data is in that link.if u paste that link in browser u can see data. the html file is stored in my system it is running in local in my browser – Nidhin Johny Aug 04 '16 at 07:13
  • Do you see error log in your console. please post it here. – The_ehT Aug 04 '16 at 07:17
  • text.html:28 Uncaught SyntaxError: missing ) after argument list only this error is shown in console – Nidhin Johny Aug 04 '16 at 07:20
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/120077/discussion-between-the-eht-and-nidhin-johny). – The_ehT Aug 04 '16 at 07:21
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/120194/discussion-between-nidhin-johny-and-the-eht). – Nidhin Johny Aug 05 '16 at 04:59

1 Answers1

1

You are getting xhttp.readyState==4 but not xhttp.status == 200. The status returned by your ajax call is 0. That's the main problem. Now there can be many reasons for this status. See here (HTTP status code 0 - what does this mean for fetch, or XMLHttpRequest?) .

Community
  • 1
  • 1
The_ehT
  • 1,202
  • 17
  • 32
  • i get this code from w3schools.com.i do not have any knowledge in ajax.i have some data in that xml link .so please help me to get data from that link – Nidhin Johny Aug 04 '16 at 06:49