on 05-24-2007 1:13 PM
Hello everybody,
I have configured an ip with a webservice. So far so good - everything works fine.
Now I want to transform the output of the webservice with xslt. The webservice returns the data as a String in form of XML.
e.g.
<!XML>
<!String>
<!String> </b>
</Bill> <!XML>
But XSLT don't find e.g the node , because it is a String. I think the right way is first to transform the String into XML. I tried this step with Java with the method
public void execute(InputStream inputStream, OutputStream outputStream)
throws StreamTransformationException {
but it doesn't work. I am not sure, if this is the right way.I have searched for a code sample, but I didn't find anything.
What do you think?
Do you have a code sample?
This would be great!
Best regards,
Jürgen
Hi,
You cannot use XSLT mapping as XSLT mapping expects the input to be XML.
What is the problem with the java Mapping?
Convert the input Stream that you get into a String and then you shold be able to do anything on the Webservice response as you want.
Regards
Bhavesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Bhavesh,
thx very much for your help.
Here is my Java Mapping:
public class ModusLebenTransformation implements StreamTransformation
{
public static byte[] readStream(InputStream in, boolean close)
throws IOException
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
int c = in.read();
while (c > -1)
{
out.write(c);
c = in.read();
}
out.flush();
byte[] result = out.toByteArray();
out.close();
if (close)
{
in.close();
}
return result;
}
public void setParameter(Map map) {
}
public void execute(InputStream inputStream, OutputStream outputStream)
throws StreamTransformationException {
try {
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
StreamResult result = new StreamResult(outputStream);
String input = new String(readStream(inputStream,true));
transformer.transform(new StreamSource(input), result);
} catch (Exception e) {
throw new StreamTransformationException("Mapping failed", e);
}
}
}
But I don't know if this code is enough to convert the String( from the webservice) into XML.
And then I would like to use XSLT for transformation in a new mapping step.
Do you think this is possible?
Do you have a code sample, that will tranform the String (from the webservice) into XML?
This would be very helpful!
regards,
Jürgen
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.