Connecting Tech Pros Worldwide Help | Site Map

HTTP POST from XSLT

Newbie
 
Join Date: Nov 2008
Posts: 4
#1: Nov 16 '08
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's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,629
#2: Nov 17 '08

re: HTTP POST from XSLT


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
Newbie
 
Join Date: Nov 2008
Posts: 4
#3: Nov 17 '08

re: HTTP POST from XSLT


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:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-
microsoft-com:xslt" xmlns:user="http://my_domain_name/my_namespace">

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

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

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

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

<xsl:variable name="returnvalue" select="document($docName)" />
<xsl:value-of select="$returnvalue"/>
</xsl:template>


</xsl:stylesheet>


The Web method is......

using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml;


/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://www.tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService {

public WebService () {

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

//[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(XmlDocument 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: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>
- <AddTwoNumbers xmlns="http://localhost/wwwroot/addnumbers/Service1">
<a>10</a>
<b>12</b>
</AddTwoNumbers>
</soap:Body>
</soap:Envelope>
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,629
#4: Nov 17 '08

re: HTTP POST from XSLT


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
Newbie
 
Join Date: Nov 2008
Posts: 4
#5: Nov 17 '08

re: HTTP POST from XSLT


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...
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,629
#6: Nov 17 '08

re: HTTP POST from XSLT


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
Moderator
 
Join Date: Mar 2006
Posts: 1,103
#7: Nov 17 '08

re: HTTP POST from XSLT


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.
Reply