HTTP POST from XSLT

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neerom
    New Member
    • Nov 2008
    • 6

    HTTP POST from XSLT

    Hi,

    I am newbie in xslt.

    I have some problem in my current project.

    I have to call web service from xslt. I have to use HTTP Post method to access webservice.

    I have got a guideline but not understanding fully....
    http://www.biglist.com/lists/xsl-list/archives/200212/msg00068.html


    Please let me know how can I write the xslt.

    Regards,
    Smaranika
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    you picked up quite a difficult topic for your start....

    well, the mentioned <post:message > was a self written extension (...) by the author, so without that, we can't help you there. The discussion went then about server interactions of xml/xslt.

    Is it absolutely necessary, that you call your webservice (SOAP?) from within XSLT? there may be other ways including other techniques, but I can't say that for sure (I don't use websevices yet).

    regards

    Comment

    • neerom
      New Member
      • Nov 2008
      • 6

      #3
      Hi

      Thanx for your reply.......

      I need to call webservice from xslt.

      I have implemented the get method:

      The sample is a addition program.

      The xslt is.....


      <?xml version="1.0" encoding="utf-8"?>

      <xsl:styleshe et version="1.0" xmlns:xsl="http ://www.w3.org/1999/XSL/Transform" xmlns:msxsl="ur n:schemas-
      microsoft-com:xslt" xmlns:user="htt p://my_domain_name/my_namespace">

      <xsl:output method="xml" omit-xml-declaration="ye s"/>

      <xsl:template match="/">
      <xsl:variable name="params" select="concat( 'x=',10,'&amp;y =',20)" />

      <xsl:variable name="CallWebSe rvice" select="'http://localhost:1600/smaranika_test/WebService.asmx/WebAdd'" />

      <xsl:variable name="docName" select="concat( $CallWebService ,'?',$params)" />

      <xsl:variable name="returnval ue" select="documen t($docName)" />
      <xsl:value-of select="$return value"/>
      </xsl:template>


      </xsl:stylesheet>


      The Web method is......

      using System;
      using System.Web;
      using System.Collecti ons;
      using System.Web.Serv ices;
      using System.Web.Serv ices.Protocols;
      using System.Xml;


      /// <summary>
      /// Summary description for WebService
      /// </summary>
      [WebService(Name space = "http://www.tempuri.org/")]
      [WebServiceBindi ng(ConformsTo = WsiProfiles.Bas icProfile1_1)]
      public class WebService : System.Web.Serv ices.WebService {

      public WebService () {

      //Uncomment the following line if using designed components
      //InitializeCompo nent();
      }

      //[WebMethod]
      //public string HelloWorld()
      //{
      // return "Hello World";
      //}
      [WebMethod]
      public int WebAdd(int x, int y)
      {
      return x + y;
      }
      [WebMethod]
      public int WebMultiply(int x, int y)
      {
      return x * y;
      }
      [WebMethod]
      public void testmethod(XmlD ocument xd)
      {

      }
      }


      Now i want to call webservice using post method. The soap is written below. Please tell me how can pass this soap message from xslt to the webservice?


      <?xml version="1.0" encoding="utf-8" ?>
      - <soap:Envelop e xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http ://www.w3.org/2001/XMLSchema" xmlns:soap="htt p://schemas.xmlsoap .org/soap/envelope/">
      - <soap:Body>
      - <AddTwoNumber s xmlns="http://localhost/wwwroot/addnumbers/Service1">
      <a>10</a>
      <b>12</b>
      </AddTwoNumbers>
      </soap:Body>
      </soap:Envelope>

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        first, please use [code] tags (or select your code, then click on the # button in the message editor menu) when posting code.

        I suppose your calculation service is just an example for something else (why add two numbers remotely except for testing something more complex...)

        also I do not see the point for the need of xslt yet. if you could be a bit more specific about the background I could be of more help.

        regards

        PS: which XSLT version are you using?
        PPS: found XSLT 2.0 SOAP extension

        Comment

        • neerom
          New Member
          • Nov 2008
          • 6

          #5
          Actually i need to call many functions one by one And have to use XSLT for that.

          I use microsoft processor. Not the saxon one...

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            that's the best I could find... but maybe it gives you a little push in the right direction (the idea there was to call soap via java)

            regards

            Comment

            • jkmyoung
              Recognized Expert Top Contributor
              • Mar 2006
              • 2057

              #7
              XSLT can only access an xml document as if it was a static document. You really need to do this coding in C# or another language.

              Comment

              Working...