XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Christian HaugSubject: Web Service response with XML string
Author: Christian Haug
Date: 15 Nov 2005 10:13 AM
I get the following response from a web service request:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<LoginResponse xmlns="http://www.sema.com/StoreSvc">
<LoginResult>&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;login&gt;&lt;code&gt;0&lt;/code&gt;&lt;desc&gt;Connected&lt;/desc&gt;&lt;token&gt;1053021&lt;/token&gt;&lt;application&gt;&lt;version&gt;2.2.543.6&lt;/version&gt;&lt;built&gt;03/11/2005 13:49&lt;/built&gt;&lt;/application&gt;&lt;/login&gt;</LoginResult>
</LoginResponse></soap:Body></soap:Envelope>

The string coming back is an XML string I would like to use the token value to create another request to the web service where I have to incorporate this value again in XML string before sending it.

The WSDL file for service looks like this, this defines the way of dealing with the web service.

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.sema.com/StoreSvc" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetNamespace="http://www.sema.com/StoreSvc" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://www.sema.com/StoreSvc">
<s:element name="Login">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="xmlLogin" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="LoginResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="LoginResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
... etc.

I do have a schema file for the login input for example. Is there a way that Stylus Studio is able to cope with this scenario or do I have to create my XML files manually all the time?

Thanks for your help.

Christian

Postnext
(Deleted User) Subject: Web Service response with XML string
Author: (Deleted User)
Date: 15 Nov 2005 01:12 PM
Christian,
Stylus will not automatically put the login token into the next web service message. You will have to do that yourself.

Please tell us your environment, are you running these web service requests manually inside Stylus? In a separate .java program? etc?

You should be able to write an .xslt which gets the token from the first response, and then inserts it into the 2nd .wscc file, creating a 3rd .wscc file which you would use once, and then throw away.

Does this address your problem?
Clyde Kessel

Postnext
Christian HaugSubject: Web Service response with XML string
Author: Christian Haug
Date: 16 Nov 2005 05:34 AM
Hello Clyde,

thanks for your answer. I didn't excpect Stylus Studio to do it by itself but I wan't to find a solution within Stylus. At the moment I am running these requests manually but the idea is to run a cascade of requests automatically where you need the output from one request as input for the next one.

My problem is that because of the way the Web service is implemented I get the answer back in an XML string in one node (here Loginresult) in the Soap envelope. I then need to map this string to an XML schema to split it up. I attach a screenshot of how it looks in the Stylus Mapper.

So I think your idea is right but I can't see how it would work by writing an .xslt since the Stylus doesn't know that Loginresult node is another XML string with several notes in it. So if you have an idea how the mapping could work it would be great.

I am running Stylus on a Windows XP system connecting to a Web Service running on a remote Windows 2003 server.

Regards

Christian


ImageXSLTmapping.gif
XSLT_Mapping

Postnext
(Deleted User) Subject: Web Service response with XML string
Author: (Deleted User)
Date: 16 Nov 2005 07:38 AM
Christian, maybe this will help.
This .xslt file will read the soap response and convert the LoginResult
element into a regular .xml file:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:value-of select="normalize-space(/)"/>
</xsl:template>
</xsl:stylesheet>

- clyde

Postnext
(Deleted User) Subject: Web Service response with XML string
Author: (Deleted User)
Date: 16 Nov 2005 08:30 AM
If you don't want to create an extra .xml file, this will extract
the token directly from the soap response.

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="raw" select="/"/>
<xsl:value-of select="substring-before(substring-after($raw, '&lt;token&gt;'), '&lt;/token&gt;')"/>
</xsl:template>
</xsl:stylesheet>


- clyde

Posttop
Christian HaugSubject: Web Service response with XML string
Author: Christian Haug
Date: 18 Nov 2005 09:17 AM
Hi Clyde,

great typ. I used the following .xslt string to create a new XML string for the next service request:

<token>
<value>
<xsl:value-of select="substring-before(substring-after(soap:Envelope/soap:Body/a:LoginResponse/a:LoginResult,&apos;&lt;token&gt;&apos;),&apos;&lt;/token&gt;&apos;)"/>
</value>
</token>

Just need to find out now how to incorporate that into the next .wscc file I call.

Thanks for your quick answer.

Christian

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.