Sibeesh Passion

Top Menu

  • Home
  • Search
  • About
  • Privacy Policy

Main Menu

  • Articles
    • Azure
    • .NET
    • IoT
    • JavaScript
    • Career Advice
    • Interview
    • Angular
    • Node JS
    • JQuery
    • Knockout JS
    • Jasmine Framework
    • SQL
    • MongoDB
    • MySQL
    • WordPress
  • Contributions
    • Medium
    • GitHub
    • Stack Overflow
    • Unsplash
    • ASP.NET Forum
    • C# Corner
    • Code Project
    • DZone
    • MSDN
  • Social Media
    • LinkedIn
    • Facebook
    • Instagram
    • Twitter
  • YouTube
    • Sibeesh Venu
    • Sibeesh Passion
  • Awards
  • Home
  • Search
  • About
  • Privacy Policy

logo

Sibeesh Passion

  • Articles
    • Azure
    • .NET
    • IoT
    • JavaScript
    • Career Advice
    • Interview
    • Angular
    • Node JS
    • JQuery
    • Knockout JS
    • Jasmine Framework
    • SQL
    • MongoDB
    • MySQL
    • WordPress
  • Contributions
    • Medium
    • GitHub
    • Stack Overflow
    • Unsplash
    • ASP.NET Forum
    • C# Corner
    • Code Project
    • DZone
    • MSDN
  • Social Media
    • LinkedIn
    • Facebook
    • Instagram
    • Twitter
  • YouTube
    • Sibeesh Venu
    • Sibeesh Passion
  • Awards
  • Linux Azure Function Isolated Dot Net 9 YAML Template Deployment

  • Build, Deploy, Configure CI &CD Your Static Website in 5 mins

  • Post Messages to Microsoft Teams Using Python

  • Get Azure Blob Storage Blob Metadata Using PowerShell

  • Deploy .net 6 App to Azure from Azure DevOps using Pipelines

JQueryPHP
Home›JQuery›Calling an ASMX Web Service From Other Server Using jQuery and PHP

Calling an ASMX Web Service From Other Server Using jQuery and PHP

By SibeeshVenu
December 29, 2013
1436
0
Share:

Introduction

A few months back, I got a requirement to fetch some inventory data from a server and show it to an HTML page. The interesting fact was the client server (the one that I want to show the data in) does not support .Net files. If did support them then we could directly add the web references and display the data. So what to do? I tried JSONP and Angular JSON but I could not make it to work. Then I came up with an idea.

Here, I have:

  • A web service that gets the data from the SQL Server 2008 DB in HTML format.
  • One HTML file where we need to show the data.
  • jQuery latest version JavaScript file.
  • Using the code

    So let’s start

    Make an HTML table in the file like the following:
    [html]
    <table id="“inventory”">
    <tbody>
    <tr id="“maintr”">
    <th>LOCATION</th>
    <th>20 GP</th>
    <th>40 FC</th>
    <th>40 GP</th>
    <th>40 OT</th>
    <th>40 HCGP</th>
    </tr>
    </tbody>
    </table>
    [/html]

    Add the JQuery reference.
    [js]
    <script src="“js/jquery-1.9.1.js”" type="“text/javascript”"></script>Add the styles to the table:
    [/js]

    Add the following Scripts to get the data from the web service:
    [js]
    <script type="“text/javascript”">// <![CDATA[
    var gp20;
    var gp40;
    var fc40;
    var ot40;
    var hcgp40;
    $(document).ready(function () {
    $(“#accordion”).accordion();
    $.post(“RetWS.php”, {
    action: “test”
    },
    function (data) {
    var className;
    var i = 0;
    var xdoc = $.parseXML(data),
    $xml = $(xdoc);
    $($xml).find(‘AvailableSaleUnitsDetail’).each(function () {
    if (i % 2 != 0) {
    className = ‘alt’;
    }
    else {
    className = ‘normal’;
    }
    if (parseInt($(this).find(‘_x0032_0GP’).text()) > 50) {
    gp20 = ’50 +’;
    }
    else {
    gp20 = $(this).find(‘_x0032_0GP’).text();
    }
    if (parseInt($(this).find(‘_x0034_0FC’).text()) > 50) {
    fc40 = ’50 +’;
    }
    else {
    fc40 = $(this).find(‘_x0034_0FC’).text();
    }
    if (parseInt($(this).find(‘_x0034_0GP’).text()) > 50) {
    gp40 = ’50 +’;
    }
    else {
    gp40 = $(this).find(‘_x0034_0GP’).text();
    }
    if (parseInt($(this).find(‘_x0034_0OT’).text()) > 50) {
    ot40 = ’50 +’;
    }
    else {
    ot40 = $(this).find(‘_x0034_0OT’).text();
    }
    if (parseInt($(this).find(‘_x0034_0HCGP’).text()) > 50) {
    hcgp40 = ’50 +’;
    }
    else {
    hcgp40 = $(this).find(‘_x0034_0HCGP’).text();
    }
    $(“#inventory”).append(“

    <tr class=” + className + ” >
    <td id=” + $(this).find(‘Location’).text() + “>” + $(this).find(‘Location’).text() + “</td>
    <td>” + gp20 + “</td>
    <td >” + fc40 + “</td>
    <td>” + gp40 + “</td>
    <td >” + ot40 + “</td>
    <td >” + hcgp40+ “</td>
    </tr>
    ”); i++;
    });
    })
    });

    // ]]>
    </script>
    [/js]

    Here, RetWS.php is my PHP file that actually gets the data from an asmx web service from another server.

    In the RetWs.php you can do the following codes:
    [php]
    <!–?php if(isset($_POST[‘action’]) &amp;&amp; !emptyempty($_POST[‘action’])) { $action = $_POST[‘action’]; switch($action) { case ‘test’ : doWebService(); break; } } function doWebService() { $client = new SoapClient(“http://Here paste link to your webservice”); echo $client-&gt;getInventoryForWs()-&gt;getInventoryForWsResult;&lt;br ?–> }
    ?&gt;
    [/php]

    The link may look like:

    http://www.something.com/Reports/Marketing/Mywebservice.asmx?WSDL
    Make sure that there are no spelling mistakes.

    Kindest Regards
    Sibeesh Vennu

    TagsCalling WebService in PHPJQueryPHPWebService
    Next Article

    DZone Most Valuable Blogger

    0
    Shares
    • 0
    • +
    • 0
    • 0
    • 0

    SibeeshVenu

    I am Sibeesh Venu, an engineer by profession and writer by passion. Microsoft MVP, Author, Speaker, Content Creator, Youtuber, Programmer.

    Related articles More from author

    • Make Image Fit To The Screen
      CodeProjectJavaScriptJQuery

      A Drag And Drop Game

      August 20, 2015
      By SibeeshVenu
    • Code SnippetsJQuery

      Remove an attribute from an html element

      May 31, 2015
      By SibeeshVenu
    • JavaScriptJQuery

      Remove a DOM element using JQuery

      July 1, 2015
      By SibeeshVenu
    • Code SnippetsJQuery

      Make a check box is checked in JQuery

      May 31, 2015
      By SibeeshVenu
    • Overwrite CSS Styles Using addClass
      CSS

      Overwrite CSS Styles Using addClass In JQuery

      October 21, 2015
      By SibeeshVenu
    • PHPWordpress

      Add related posts in each posts in WordPress

      July 14, 2015
      By SibeeshVenu
    0

    My book

    Asp Net Core and Azure with Raspberry Pi Sibeesh Venu

    YouTube

    MICROSOFT MVP (2016-2022)

    profile for Sibeesh Venu - Microsoft MVP

    Recent Posts

    • React Native Android Release with Azure DevOps and Google Play Store
    • Linux Azure Function Isolated Dot Net 9 YAML Template Deployment
    • Build, Deploy, Configure CI &CD Your Static Website in 5 mins
    • Easily move data from one COSMOS DB to another
    • .NET 8 New and Efficient Way to Check IP is in Given IP Range
    • Async Client IP safelist for Dot NET
    • Post Messages to Microsoft Teams Using Python
    • Get Azure Blob Storage Blob Metadata Using PowerShell
    • Deploy .net 6 App to Azure from Azure DevOps using Pipelines
    • Integrate Azure App Insights in 1 Minute to .Net6 Application

    Tags

    Achievements (35) Angular (14) Angular 5 (7) Angular JS (15) article (10) Article Of The Day (13) Asp.Net (14) Azure (65) Azure DevOps (10) Azure Function (10) Azure IoT (7) C# (17) c-sharp corner (13) Career Advice (11) chart (11) CSharp (7) CSS (7) CSS3 (6) HighChart (10) How To (9) HTML5 (10) HTML5 Chart (11) Interview (6) IoT (11) Javascript (10) JQuery (82) jquery functions (9) JQWidgets (15) JQX Grid (17) Json (7) Microsoft (8) MVC (20) MVP (9) MXChip (7) News (18) Office 365 (7) Products (10) SQL (20) SQL Server (15) Visual Studio (10) Visual Studio 2017 (7) VS2017 (7) Web API (12) Windows 10 (7) Wordpress (9)
    • .NET
    • Achievements
    • ADO.NET
    • Android
    • Angular
    • Arduino
    • Article Of The Day
    • ASP.NET
    • Asp.Net Core
    • Automobile
    • Awards
    • Azure
    • Azure CDN
    • azure devops
    • Blockchain
    • Blog
    • Browser
    • C-Sharp Corner
    • C#
    • Career Advice
    • Code Snippets
    • CodeProject
    • Cognitive Services
    • Cosmos DB
    • CSS
    • CSS3
    • Data Factory
    • Database
    • Docker
    • Drawings
    • Drill Down Chart
    • English
    • Excel Programming
    • Exporting
    • Facebook
    • Fun
    • Gadgets
    • GitHub
    • GoPro
    • High Map
    • HighChart
    • How to
    • HTML
    • HTML5
    • Ignite UI
    • IIS
    • Interview
    • IoT
    • JavaScript
    • JQuery
    • jQuery UI
    • JQWidgets
    • JQX Grid
    • Json
    • Knockout JS
    • Linux
    • Machine Learning
    • Malayalam
    • Malayalam Poems
    • MDX Query
    • Microsoft
    • Microsoft ADOMD
    • Microsoft MVP
    • Microsoft Office
    • Microsoft Technologies
    • Microsoft Windows
    • Microsoft Windows Server
    • Mobile
    • MongoDB
    • Monthly Winners
    • MVC
    • MVC Grid
    • MySQL
    • News
    • Node JS
    • npm
    • Number Conversions
    • October 2015
    • Office 365
    • Office Development
    • One Plus
    • Outlook
    • Page
    • PHP
    • Poems
    • PowerShell
    • Products
    • Q&A
    • Raspberry PI
    • React
    • SEO
    • SharePoint
    • Skype
    • Social Media
    • Software
    • Spire.Doc
    • Spire.PDF
    • Spire.XLS
    • SQL
    • SQL Server
    • SSAS
    • SSMS
    • Storage In HTML5
    • Stories
    • Third Party Software Apps
    • Tips
    • Tools
    • Translator Text
    • Uncategorized
    • Unit Testing
    • UWP
    • VB.Net
    • Videos
    • Virtual Machine
    • Visual Studio
    • Visual Studio 2017
    • Wamp Server
    • Web API
    • Web Platform Installer
    • Webinars
    • WebMatrix
    • Windows 10
    • Windows 7
    • Windows 8.1
    • Wordpress
    • Writing

    ABOUT ME

    I am Sibeesh Venu, an engineer by profession and writer by passion. Microsoft MVP, Author, Speaker, Content Creator, Youtuber, Programmer. If you would like to know more about me, you can read my story here.

    Contact Me

    • info@sibeeshpassion.com

    Pages

    • About
    • Search
    • Privacy Policy
    • About
    • Search
    • Privacy Policy
    © Copyright Sibeesh Passion 2014-2025. All Rights Reserved.
    Go to mobile version