cancel
Showing results for 
Search instead for 
Did you mean: 

problem Java Mapping

former_member200339
Participant
0 Kudos

hi forum,

I am using java mapping, to transform a Message type (actually a external definition) to another (in a interface mapping), actually the mapping produces the same XML as the input,

there is problem which i have observed,

the root element of the XML has a attribute which belongs to a different namespace from that of the root elemnet itself,

it looks like the following:

<ns0:add ns1:encodingStyle="" xmlns:ns0="http://localhost:8080/axis/CalculatorTruncate.jws" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">

<a><a/>

<b></b>

</ns0:add>

on executing the javamapping it gives an error:

--Exception during serialization: javax.xml.transform.TransformerException: Namespace fixup failed. Prefix 'ns1' used in attribute 'ns1:encodingStyle' is not declared anywhere

which is absolutely wrong,

but, when i deliberately removed that namespace prefix from the attribute (encodingStyle) of the root element, it works well,

but i need that namespace prefix attached.

Is it a bug with javamapping, or am i going wrong somewhere,

please help........

please note that i have imported XSDs from outside, and they are well formed and validated.

Accepted Solutions (0)

Answers (5)

Answers (5)

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi Rana,

What you written JAVA Code is correct,your source data has already one name space appended at ns0 level,when you run java map it will append original name space at ns0 level, but it has alredy one name space tag , thats why its trowning exception.

what you if you want<ns0> filed apend in in next level ns1 level and try to run once , or append in some other place using java code.

Regards,

raj

Former Member
0 Kudos

Kindly check this [http://www.w3.org/2000/xp/Group/1/10/11/soap12-part2.html#httpexamples]

former_member200962
Active Contributor
0 Kudos
Prefix 'ns1' used in attribute 'ns1:encodingStyle' is not declared anywhere

whatever prefixes you use ns1, ns0 etc have to be declared in your javamapping also......it is not a bug of the javamapping just an indicator that you forgot to declare the prefix....

You will get a same error even with XSLT mapping if ns1 is not declared....in XSLT declaration means associate the prefix ns1 with some namespace...target namespace....

So you need to do a similar change here...

Also i dont think this is a tool / jar file related issue....you will get it acorss all the tools and even if you include all the jar files...

Regards,

Abhishek

Edited by: abhishek salvi on May 12, 2009 10:22 AM

former_member200339
Participant
0 Kudos

<<whatever prefixes you use ns1, ns0 etc have to be declared in your javamapping also......>>

it is perfectly declared....see the XML

<ns0:add ns1:encodingStyle="" xmlns:ns0="http://localhost:8080/axis/CalculatorTruncate.jws" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">

former_member200962
Active Contributor
0 Kudos

This line: xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/

should come before ns1:encodingStyle="".......

when you code is executed it is searching for the declaration for ns1 associated with encodingStyle and since it can't find....you get the error......so the point is first declare the prefixes and then use them..

former_member200339
Participant
0 Kudos

<<when you code is executed it is searching for the declaration for ns1 associated with encodingStyle and since it can't find....you get the error......so the point is first declare the prefixes and then use them..>>

this is not working

prasannakrishna_mynam
Contributor
0 Kudos

Hello Rana,

If this works well in your NWSD and not in your Interface Mapping, Try to check whether you have missed any jar files to import explicitly. Other wise if its get error in your NWSD add the libraries regading to this.

Regards,

Prasanna

former_member200339
Participant
0 Kudos

Hi,

i have tried this java mapping in NWDS using/importing the following classes

import java.io.*;

import java.util.*;

import com.sap.aii.mapping.api.*;

import javax.xml.parsers.*;

import org.w3c.dom.*;

import org.xml.sax.SAXException;

and it works well in NWDS,

if i do the same mapping using graphical mapping in XI. it does well.

only the problem is in using java mapping, and that too when using a namespace prefix with attributes, example ns1:encodingStyle="myStyle",

Mario, u said <<there should be an error in the xmltoolkit (which is used/processed by XI)

>>

what is xmltoolkit, can i download it and use in a standalone environment (outside XI)

Former Member
0 Kudos

Hi rana,

did you run your programm in a "local" IDE like eclipse?

If yes: ECLIPSE does not use the sapxmltoolkit. If the error is not there, there should be an error in the xmltoolkit (which is used/processed by XI)

Regards Mario