Java - XML mapping
I want to generate/map a xml schema from a set of java classes (like JAXB or XMLBeans).
This not for a web service implementation. Is there any I can use the autotype
ant task available in weblogic webservice to achieve this ?
Thanks,
Siva
http://newsgroups.bea.com/cgi-bin/dnewsweb?cmd=article&group=weblogic.developer.interest.webservices&item=4956
Siva wrote:
>
I want to generate/map a xml schema from a set of java classes (like JAXB or XMLBeans).
This not for a web service implementation. Is there any I can use the autotype
ant task available in weblogic webservice to achieve this ?
Thanks,
Siva
Similar Messages
-
Customize -java-wsdl-mapping.xml with EJB3 web service
Using OC4J 10.1.3, I have an EJB that I am exposing as a web service using JSR-181 annotations. Is it possible to customize the generated <ServiceName>-java-wsdl-mapping.xml file? I tried putting my own version in META-INF/ of my ejb jar, but it didn't seem to pick up on it.
I was told the product manager and/or developers from Oracle watched this board. Doesn't anyone have a response to this?
-
Using Java XML 1.5 toolkit instead of sapxmltoolkit for xslt mappings
Hi All
We have a case whereby our xlst requires a number of customised java class functions as we are porting webmethods systems across to PI.
eg in the xslt adding
<xsl:when test="function-available('java:concat">
<xsl:value-of select="java:concat($first, $last, $inputparam)"/>
We are running sap PI 7.1 ehp1. I have been referring to a number of posts on how to complete these tasks.
namely we have implemented the example as provided in:
http://help.sap.com/saphelp_nwpi71/helpdata/EN/73/f61eea1741453eb8f794e150067930/frameset.htm
This only works if "Sap XML Toolkit" is enabled in the operational mapping.
Left unticked (default setting in the mapping) whenever a testcase is run I end up with the error "could not compile sytle sheet".
I would like to use the Java 1.5 xml processing capability as it is supposed to perform better than the sapxmltoolkit option and support for the latter will be discontinued in future.
Has anyone been able run the case with sapxmltoolkit enabled?
If so did you add any other libraries for java xml 1.5?
thanksThanks, I would have thought as much, but theres no guide on the deployment.
For now i assume this will fit into the java/ext area and Pi would need a reboot after the libraries are copied.
Has anyone deployed the additional libraries to PI. -
Problem with castor xml mapping
Hi,
we have following problem with castor xml mapping.
How to use references in the collections(Hashmap or vector)?
WE have a method called getAttribute map which will return a hashmap consist different type of objects. We want to keep only the
references of objects if that object occurs more than once,instead of keeping the whole object
Following is the the xml mapping file.
<mapping>
<class name="com.opvista.ndtool.core.mos.ManagedObject" identity="Id" auto-complete="false" verify-constructable="false">
<map-to xml="ManagedObject"/>
<field name="Id" get-method="getId" set-method="setId" type="string">
<bind-xml name="Id" node="attribute"/>
</field>
<field name="AttributeMap" type="org.exolab.castor.mapping.MapItem" collection="map" get-method="getAttributeMap">
<bind-xml name="AttributeMap" node="element">
<class name="org.exolab.castor.mapping.MapItem">
<field name="key" type="java.lang.Object">
<bind-xml name="key" node="attribute"/>
</field>
<field name="value" type="java.lang.Object">
<bind-xml name="value" node="element" reference="true"/>
</field>
</class>
</bind-xml>
</field>
</class>
</mapping>
we are using reference=true for the values. But it will throw below exception.
Unable to resolve ID for instance of class 'java.lang.String' due to the following error: Unable to resolve ClassDescriptor.
at org.exolab.castor.xml.Marshaller.getObjectID(Marshaller.java:1988)
at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:1628)
at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:1831)
at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:1814)
at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:1825)
at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:821)
Please help us to overcome from this problem?
Thanks,
Dileepfor your ref here is what i think the basic mapping file would look like
<class name="Person">
<map-to xml="person"/>
<field name="name" type="string">
<bind-xml name="name" node="attribute" />
</field>
<field name="age" type="string">
<bind-xml name="age" node="attribute" />
</field>
</class>
<class name="MetaPerson">
<map-to xml="person"/>
<field name="dependents" type="string">
<bind-xml name="dependents" node="attribute" />
</field>
<field name="presentAdd" type="string">
<bind-xml name="present_add " node="attribute" />
</field>
<field name="permanentAdd" type="string">
<bind-xml name="permanent_add " node="attribute" />
</field>
</class>
however i am still not clear as to how i can use the metaperson object in the person class as well as in the mapping file.
hope this gives a better idea abt my problem statement.
Please help me out -
JAVA Sax mapping replaces &_amp; with & causing mapping to fail
Hi all,
I have the following mapping scenario:
Source XML -> Java Sax Mapping -> Graphical Mapping -> Target structure
The source XML is valid and caters for special characters like & which appear as &_amp; in the XML (ignore the underscore _ without it the editor strips the amp;, isn't that ironic!).
The second step of the interface mapping, which is the graphical map, is failing. It seems that the Java Sax mapping is replacing &_amp; with & in the XML, which is then causing the graphical map to fail as it cannot handle the special character &.
Is there anyway I can prevent the Java Sax mapping from changing & to &
Or is the only solution for me to write extra code in the Java map to convert & back to &_amp; before passing to the second mapping step????
Any help appreciated.
Che
Edited by: Che Eky on Feb 18, 2009 11:05 PMHi..
Use this in your source xml file for '&' ->"&_amp;" remove the underscore
Regards..
Krishna..
Edited by: PrasannaKrishna Mynam on Feb 19, 2009 2:20 PM
Edited by: PrasannaKrishna Mynam on Feb 19, 2009 2:20 PM -
oms_error Message:[oms] empty or null xml map request string.
I'm using mapviewer. I create a stored procedure in oracle that uses the utl_http package to make the map request. The omserver response with an error but when i make a map request via internet explorer the server response its ok and show me the correspondent map. This is my pl/sql code it fails in this line:
UTL_HTTP.SET_HEADER(l_http_req, 'Content-Type', 'application/x-www-form-urlencoded');
UTL_HTTP.SET_HEADER(l_http_req, 'Content-Lenght', LENGTH(map_request));
UTL_HTTP.SET_HEADER(l_http_req, 'Host', 'cobogis09');
UTL_HTTP.SET_HEADER(l_http_req, 'Port', '8888');
As you can see it tells to me that the map request string is empty but im sending the map request in the next way:
UTL_HTTP.WRITE_TEXT(l_http_req, '<?xml version="1.0" encoding="UTF-8"?><map_request datasource="stream" srid="8307" basemap="" width="960" height="768" antialiasing="false" format="GIF_URL" title="Demonstration"></map_request>');
l_http_resp := utl_http.get_response(l_http_req);
utl_http.read_text(l_http_resp, l_value);
response := sys.XMLTYPE.createxml(l_value);
utl_http.end_response(l_http_resp);
img_url := response.EXTRACT('/map_response/map_image/map_content/@url').getstringval();
img_url := response.EXTRACT('/map_response/map_image/map_content/@url').getstringval();
obviously because the server response its not ok
the server response is (i get this message in my l_value variable):
<?xml version="1.0" encoding="UTF-8"?><oms_error>Message:[oms] empty or null xml map request string.
Tue Jul 25 10:37:43 GMT-05:00 2006
Severity: 0
Description:
at oracle.lbs.mapserver.oms.getXMLDocument(oms.java:860)
at oracle.lbs.mapserver.oms.doPost(oms.java:303)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:285)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:126)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:595)
</oms_error>
What i want to know its why the server says that the map request string is empty. As you can see the map request is not empty, but when i send to the server something happens that sends this map request string empty to the server.
The next is the console of the omserver:
C:\oc4j_extended>cd\
C:\>cd C:\oc4j_extended\j2ee\home
C:\oc4j_extended\j2ee\home>java -hotspot -Xmx512M -jar oc4j.jar
06/07/25 11:00:49 INFO [oracle.lbs.mapserver.oms] oms root path: C:\oc4j_extended\j2ee\home\lbs\mapviewer\web\
06/07/25 11:00:49 Oracle Application Server Containers for J2EE 10g (10.1.2.0.2) initialized
06/07/25 11:00:49 INFO [oracle.lbs.mapserver.core.MapperConfig] using default config file: C:\oc4j_extended\j2ee\home\lbs\mapviewer\web\WEB-INF\conf\mapViewerConfig.xml
06/07/25 11:00:49 WARN [oracle.lbs.mapserver.core.MapperPool] destroying ALL mapmaker instances.
06/07/25 11:00:50 INFO [oracle.lbs.mapserver.core.MapperConfig] setting logging level to finest
06/07/25 11:00:50 Tue Jul 25 11:00:50 GMT-05:00 2006 INFO [oracle.sdovis.CacheMgr2] In memory cache limit set to: 512MB
06/07/25 11:00:50 Tue Jul 25 11:00:50 GMT-05:00 2006 INFO [oracle.lbs.mapserver.core.MapperConfig] Disk-based cache is no longer supported.
06/07/25 11:00:50 Tue Jul 25 11:00:50 GMT-05:00 2006 INFO [oracle.lbs.mapserver.core.MapperConfig] setting proxy to: coboisa01.ag.ad.local:8080
06/07/25 11:00:50 Tue Jul 25 11:00:50 GMT-05:00 2006 FINEST [oracle.lbs.mapserver.core.MapperConfig]
Allowed IPs:
Excluded IPs:
06/07/25 11:00:50 Tue Jul 25 11:00:50 GMT-05:00 2006 ERROR [oracle.lbs.mapserver.core.MapperConfig] ###### [MapperConfig] clear-text passwords in the mapViewrConfig.xml file must be prefixed with a '!' (exclamation mark).
06/07/25 11:00:50 Tue Jul 25 11:00:50 GMT-05:00 2006 INFO [oracle.lbs.mapserver.core.MapperConfig] Map Recycling thread started.
06/07/25 11:00:50 Tue Jul 25 11:00:50 GMT-05:00 2006 INFO [oracle.lbs.mapserver.oms] *** Oracle MapViewer started. ***
06/07/25 11:01:03 Tue Jul 25 11:01:03 GMT-05:00 2006 FINEST [oracle.lbs.mapserver.oms] request.getRemoteUser = jazn.com/admin
06/07/25 11:01:03 Tue Jul 25 11:01:03 GMT-05:00 2006 FINEST [oracle.lbs.mapserver.oms] request= <?xml version="1.0" standalone="yes"?>
<non_map_request>
<add_data_source name="stream"
jdbc_host="cobodata01"
jdbc_sid="stream"
jdbc_port="1521"
jdbc_user="***"
jdbc_password="***"
jdbc_mode="thin"
number_of_mappers="3"/>
</non_map_request>
06/07/25 11:01:03 Tue Jul 25 11:01:03 GMT-05:00 2006 FINEST [oracle.lbs.mapserver.oms] getRequestType: nodeName=add_data_source
06/07/25 11:01:03 Tue Jul 25 11:01:03 GMT-05:00 2006 INFO [oracle.lbs.mapserver.MapServerImpl] adding a map data src [name=stream]
06/07/25 11:01:05 Tue Jul 25 11:01:05 GMT-05:00 2006 FINEST [oracle.sdovis.SRS] loaded 748 geodetic srids.
06/07/25 11:01:05 Tue Jul 25 11:01:05 GMT-05:00 2006 INFO [oracle.sdovis.CacheMgr2] Spatial Data Cache opened. Region=SDOVIS_DATA.
06/07/25 11:01:05 Tue Jul 25 11:01:05 GMT-05:00 2006 INFO [oracle.sdovis.CacheMgr2] max_cache_size=512 MB.
06/07/25 11:01:05 Tue Jul 25 11:01:05 GMT-05:00 2006 INFO [oracle.sdovis.CacheMgr2] sub region sdovis_subreg_gis_jdbc:oracle:thin:@cobodata01:1521:stream created in cache.
06/07/25 11:01:05 Tue Jul 25 11:01:05 GMT-05:00 2006 INFO [oracle.lbs.mapserver.core.MapperPool] added a mapper instance to the pool [data src=stream]
06/07/25 11:01:05 Tue Jul 25 11:01:05 GMT-05:00 2006 INFO [oracle.lbs.mapserver.core.MapperPool] added a mapper instance to the pool [data src=stream]
06/07/25 11:01:06 Tue Jul 25 11:01:06 GMT-05:00 2006 INFO [oracle.lbs.mapserver.core.MapperPool] added a mapper instance to the pool [data src=stream]
06/07/25 11:01:36 Tue Jul 25 11:01:36 GMT-05:00 2006 FINEST [oracle.lbs.mapserver.oms] request.getRemoteUser = null
06/07/25 11:01:36 Tue Jul 25 11:01:36 GMT-05:00 2006 FINEST [oracle.lbs.mapserver.oms] request= null
As you can see the arrive empty to the server, what can be wrongHi,
in this map request, it looks that the basemap string is empty.
UTL_HTTP.WRITE_TEXT(l_http_req, '<?xml version="1.0" encoding="UTF-8"?><map_request datasource="stream" srid="8307" basemap="" width="960" height="768" antialiasing="false" format="GIF_URL" title="Demonstration"></map_request>'); -
Java Class Mapping Program in BPM process
I have a scenario where I'm receiving an IDOC I then use a JAVA mapping program in my first transformation step. Immediately following I have a switch step but there is not data in from the mapping program.
1) Receive Step
2) Transformation IDOC to Table using Java class
3) Switch step based on Table field value
Problem is there is no values in the table.
This java class was not developed within NetWeaver but was used in our old process. We simply imported the jar file for accessing our existing java classes. Is there something else we need to do to utilize our java modules within the BPM process?Hi,
You must to have in the java class:
- You java have to be like:
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
import java.util.HashMap;
import com.sap.aii.mapping.api. AbstractTrace;
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.StreamTransformationConstants;
public class JavaMapping implements StreamTransformation {
private Map param = null;
private AbstractTrace trace = null;
public void setParameter (Map param) {
this.param = param;
if (param == null) {
this.param = new HashMap();
public void execute(InputStream in, OutputStream out) {
try {
trace = (AbstractTrace)param.get(
StreamTransformationConstants.MAPPING_TRACE );
trace.addInfo(...);
String receiverName = (String)param.get(
StreamTransformationConstants.RECEIVER_NAME);
The method execute take the InputStream with the XML source. The out (OutputStream) have to be an XML like the IDOC structure.
Regards. -
Problems with Java DOM Mapping
Hi Experts,
as part of my diploma-thesis I have to write a java DOM-Mapping, which mapps the following incoming message:
<mt_MappingOUT>
<set>
<set_Element_01>...</set_Element_01>
<set_Element_02>... </set_Element_02>
<set_Element_03>... </set_Element_02>
<set_Element_10> </set_Element_10>
</set>
</mt_MappingOUT>
to the following outgoinig message:
<mt_MappingIN>
<TABLE>
<item>
<item_FIELD_01> </item_FIELD_01>
<item_FIELD_10> <item_FIELD_10>
<i/tem>
</TABLE>
</mt_MappingIN>
I am not a very experienced Java-Developer. You can see my code down there, which I tried to implement according to some bloggs; unfortunately the result is not what I want to have
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
import org.xml.sax.SAXException;
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
public class DOMMAPPING implements StreamTransformation{
public static void main(String[] args) throws Exception
try
FileInputStream fin =
new FileInputStream("C:/mt_MappingOut.xml");
FileOutputStream fout =
new FileOutputStream("C:/target.xml");
DOMMAPPING mapping = new DOMMAPPING();
mapping.execute(fin, fout);
catch (Exception e) {
e.printStackTrace();
public void setParameter (Map param) {}
public void execute (InputStream in, OutputStream out)
throws com.sap.aii.mapping.api.StreamTransformationException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
Document documentIn = null;
DocumentBuilder builder = null;
try {
builder = factory.newDocumentBuilder();
} catch (ParserConfigurationException e1) {
e1.printStackTrace();
try {
Element itemNode = null;
NodeList[] list_f=new NodeList[10];
Element[] field=new Element[10];
documentIn = builder.parse(in);
Document documentOut = builder.newDocument();
Element rootNode = documentOut.createElementNS("urn:agrp:xi:geissseb","ns0:mt_MappingIn");
documentOut.appendChild(rootNode);
Element tableNode = documentOut.createElement("TABLE");
rootNode.appendChild(tableNode);
NodeList list_Set=documentIn.getElementsByTagName("set");
System.out.println(list_Set.getLength());
for(int j=1;j<10;j++){
list_f[j-1]=documentIn.getElementsByTagName("set_ELEMENT_01"+j);
list_f[9]=documentIn.getElementsByTagName("set_ELEMENT_10");
//NodeList list_f01=documentIn.getElementsByTagName("f01");
for (int i=0;i<list_Set.getLength();i++)
itemNode=documentOut.createElement("item");
tableNode.appendChild(itemNode);
for(int k=0; k<10;k++){
Node f=list_f[k].item(i);
f=f.getFirstChild();
String str_f=f.getNodeValue();
Text text_f=documentOut.createTextNode(str_f);
field[k]=documentOut.createElement("item_FIELD_"(k1));
field[k].appendChild(text_f);
itemNode.appendChild(field[k]);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transform = tf.newTransformer();
transform.transform(new DOMSource(documentOut), new StreamResult(out));
} catch (SAXException e2) {
e2.printStackTrace();
} catch (IOException e2) {
e2.printStackTrace();
}catch (Throwable t) { throw new StreamTransformationException("error", t); }
Unfortunately there seems to be at least one error in there because the result I get is just the following:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
- <ns0:mt_MappingIn xmlns:ns0="urn:agrp:xi:geissseb">
<TABLE />
</ns0:mt_MappingIn>
Below you will find my source message:
<?xml version="1.0" encoding="UTF-8" ?>
- <xsd:schema targetNamespace="urn:agrp:xi:geissseb" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:agrp:xi:geissseb">
<xsd:element name="mt_MappingOut" type="dt_MappingOut" />
- <xsd:complexType name="dt_MappingOut">
- <xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">a7a28830bebf11dc81aa001a4b0af224</xsd:appinfo>
</xsd:annotation>
- <xsd:sequence>
- <xsd:element name="Set">
- <xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">0b366510aeda11dcb3bb00174205b856</xsd:appinfo>
</xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="f01" type="xsd:string">
- <xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">0b366511aeda11dcaf2600174205b856</xsd:appinfo>
</xsd:annotation>
</xsd:element>
- <xsd:element name="set_ELEMENT_02" type="xsd:string">
- <xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">0b366512aeda11dc84d400174205b856</xsd:appinfo>
</xsd:annotation>
</xsd:element>
- <xsd:element name="set_ELEMENT_03" type="xsd:string">
- <xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">0b366513aeda11dcbcab00174205b856</xsd:appinfo>
</xsd:annotation>
</xsd:element>
- <xsd:element name="set_ELEMENT_04" type="xsd:string">
- <xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">0b366514aeda11dc96a300174205b856</xsd:appinfo>
</xsd:annotation>
</xsd:element>
- <xsd:element name="set_ELEMENT_05" type="xsd:string">
- <xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">0b366515aeda11dca77700174205b856</xsd:appinfo>
</xsd:annotation>
</xsd:element>
- <xsd:element name="set_ELEMENT_06" type="xsd:string">
- <xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">0b366516aeda11dc8f7d00174205b856</xsd:appinfo>
</xsd:annotation>
</xsd:element>
- <xsd:element name="set_ELEMENT_07" type="xsd:string">
- <xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">0b366517aeda11dcc24b00174205b856</xsd:appinfo>
</xsd:annotation>
</xsd:element>
- <xsd:element name="set_ELEMENT_08" type="xsd:string">
- <xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">0b366518aeda11dc92cd00174205b856</xsd:appinfo>
</xsd:annotation>
</xsd:element>
- <xsd:element name="set_ELEMENT_09" type="xsd:string">
- <xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">0b366519aeda11dcc9b100174205b856</xsd:appinfo>
</xsd:annotation>
</xsd:element>
- <xsd:element name="set_ELEMENT_10" type="xsd:string">
- <xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">0b36651aaeda11dcc5a700174205b856</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
When I had problems withe Java SAX Mapping, I got great hints in the forum. So I hope you can help me out again...
Cheers SebastianHere you go.
Code
package com.sap.test;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.apache.crimson.tree.TextNode;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
import org.xml.sax.SAXException;
import com.sap.aii.mapping.api.StreamTransformationException;
public class DomTest {
Document documentOut = null;
public static void main(String[] args) throws Exception
try
FileInputStream fin = new FileInputStream("test.xml");
FileOutputStream fout = new FileOutputStream("test_out.xml");
DomTest mapping = new DomTest();
mapping.execute(fin, fout);
catch (Exception e) {
e.printStackTrace();
public void setParameter (Map param) {}
public void execute (InputStream in, OutputStream out)
throws com.sap.aii.mapping.api.StreamTransformationException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
Document documentIn = null;
DocumentBuilder builder = null;
try {
builder = factory.newDocumentBuilder();
} catch (ParserConfigurationException e1) {
e1.printStackTrace();
try {
Element itemNode = null;
//NodeList[] list_f=new NodeList10;
//Element[] field=new Element10;
documentIn = builder.parse(in);
documentOut = builder.newDocument();
Element rootNode = documentOut.createElementNS("urn:agrp:xi:geissseb","ns0:mt_MappingIn");
rootNode.setAttribute("xmlns:ns0", "urn:agrp:xi:geissseb");
documentOut.appendChild(rootNode);
Element tableNode = documentOut.createElement("TABLE");
rootNode.appendChild(tableNode);
NodeList list_Set = documentIn.getElementsByTagName("set");
System.out.println(list_Set.getLength());
for(int j = 0 ; j < list_Set.getLength() ;j++){
Element setNode = (Element)list_Set.item(j);
NodeList children = setNode.getChildNodes();
for(int index = 0; index < children.getLength(); index++)
Node child = children.item(index);
if (child instanceof Element) {
Element element = (Element) child;
if(element.getNodeName().startsWith("set_ELEMENT"))
createItemFeildNode(tableNode,element);
//list_f[9]=documentIn.getElementsByTagName("set_ELEMENT_10");
// NodeList list_f01=documentIn.getElementsByTagName("f01");
/*for (int i=0;i<list_Set.getLength();i++)
itemNode=documentOut.createElement("item");
tableNode.appendChild(itemNode);
for(int k=0; k<10;k++){
Node f=list_f[k].item(i);
f=f.getFirstChild();
String str_f=f.getNodeValue();
Text text_f=documentOut.createTextNode(str_f);
field[k]=documentOut.createElement("item_FIELD_"(k1));
field[k].appendChild(text_f);
itemNode.appendChild(field[k]);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transform = tf.newTransformer();
transform.transform(new DOMSource(documentOut), new StreamResult(out));
transform.transform(new DOMSource(documentOut), new StreamResult(System.out));
} catch (SAXException e2) {
e2.printStackTrace();
} catch (IOException e2) {
e2.printStackTrace();
}catch (Throwable t) { throw new StreamTransformationException("error", t); }
private void createItemFeildNode(Element root, Element element) {
String inName = element.getNodeName();
int temp = inName.lastIndexOf('_');
if (temp == -1)
return;
String index = inName.substring(temp+1);
String nodeName = "Item_FIELD_" + index;
String nodeVal = element.getFirstChild().getNodeValue();
Element newElement = documentOut.createElement(nodeName);
Text txtNode = documentOut.createTextNode(nodeVal);
newElement.appendChild(txtNode);
root.appendChild(newElement);
Input
<?xml version="1.0" encoding="UTF-8" ?>
<mt_MappingOut xmlns="urn:agrp:xi:geissseb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:agrp:xi:geissseb file:/D:/Eclipse/workspace/SDN/test.xsd">
<set xmlns="">
<set_ELEMENT_01>E1</set_ELEMENT_01>
<set_ELEMENT_02>E2</set_ELEMENT_02>
<set_ELEMENT_03>E3</set_ELEMENT_03>
<set_ELEMENT_04>E4</set_ELEMENT_04>
<set_ELEMENT_05>E5</set_ELEMENT_05>
<set_ELEMENT_06>E6</set_ELEMENT_06>
<set_ELEMENT_07>E7</set_ELEMENT_07>
<set_ELEMENT_08>E8</set_ELEMENT_08>
<set_ELEMENT_09>E9</set_ELEMENT_09>
<set_ELEMENT_10>E10</set_ELEMENT_10>
</set>
</mt_MappingOut>
Output
<?xml version="1.0" encoding="UTF-8" ?>
<ns0:mt_MappingIn xmlns:ns0="urn:agrp:xi:geissseb">
<TABLE>
<Item_FIELD_01>E1</Item_FIELD_01>
<Item_FIELD_02>E2</Item_FIELD_02>
<Item_FIELD_03>E3</Item_FIELD_03>
<Item_FIELD_04>E4</Item_FIELD_04>
<Item_FIELD_05>E5</Item_FIELD_05>
<Item_FIELD_06>E6</Item_FIELD_06>
<Item_FIELD_07>E7</Item_FIELD_07>
<Item_FIELD_08>E8</Item_FIELD_08>
<Item_FIELD_09>E9</Item_FIELD_09>
<Item_FIELD_10>E10</Item_FIELD_10>
</TABLE>
</ns0:mt_MappingIn> -
Hi,
I believe this is possible but cannot determine what Toplink API to use from the documentation. I'd like to convert a simple Java Object (with just standard getter and setter methods) into an XML string IN MEMORY, then from that String, back to the original Java object. No databases involved, no mapping involved. Should be little more than 2 lines of code by my reckoning!
So does anyone know the API or point me to a code example?
Thanks
MikeHi Mike,
TopLink 10.1.3 introduces object-to-XML mapping support. Similar to relational TopLink, the Mapping Workbench is used to visually map your existing classes (these classes are NOT required to implement any special interfaces or follow any naming conventions) to an existing XML Schema.
The TopLink OX mappings are XPath based and make use of path and position mechanisms to eliminate the requirement of having a 1-to-1 correspondence between the object model and XML Schema. This limitation is common among code generated O-X tools.
TopLink OX provides a standard JAXB 1.0 implementation and the JAXB runtime APIs can be used to perform the conversion. TopLink also provides its own conversion APIs that provide additional functionality. In your example you would marshal your objects to a java.io.StringWriter, and unmarshal it from a java.io.StringReader.
TopLink's OX support does not involve a database, but you can combine it with TopLink's persistence layer to access data sources that accept XML records.
TopLink 10.1.3 Developer Preview release notes - Object-XML (OX) Support
http://www.oracle.com/technology/products/ias/toplink/preview/relnotes/tl_relnotes.htm#BABGEIID
Example Code - Using TopLink OX to implement a custom serializer/deserializer
http://www.oracle.com/technology/products/ias/toplink/preview/howto/websrv/index.htm
-Blaise -
XML mapped directly into dbtable
Hi guys,
I've one doubt related to xml mapping. I've searched and read lots of posts on the forum about XML, but the doubt is still remaining...
Imagine I have a XML response to an webservice and I'd like to pass it to an dbtable.
I know I can use DOM to parse the xml, and I've even seen I can build a table based on hierarchies nodes, but what I'd like to know is if it's possible to pass all the content from the XML directly to my dbtable.
Why do I want to do this? Because the xml which is sent is really huge, and if I'd have to parse it, there would be tons of abap code.... So, I'd like to pass it directly to my table...
I could validate the xml with a DTD and then if there were no errors, I would pass it directly to the dbtable...
Is there any way of doing it?
I'm really thankful for your answers....Hi,
If you are looking at passing the whole XML response into a field in the target, this would be simple.
Convert the InputStream ( In Java Mapping) into a string and pass it to the String.
You can use this code to convert InputStream to string,
In this code, <b>in</b> is the inputstream to the execute() of java mapping,
BufferedReader inp = new BufferedReader(new InputStreamReader(in));
StringBuffer buffer = new StringBuffer();
String line="";
while ((line = inp.readLine()) != null) {
buffer.append(line);
String source=buffer.toString();
is this what you are looning at?
Regards,
Bhavesh -
Java.util.Map type return in webservice method
Wonder, how we can return a java.util.Map type from a webservice deployed on a
weblogic 7.x environment..
any input is appreciated.
-GirishThanks Michael. it helps.
-Girish
"Michael Wooten" <[email protected]> wrote:
>
Hi Girish,
By definition, a Java object used as a input parameter (or return type)
of a web
service operation, must has a no-arg constructor in order for a Java-based
Web
Service Stack to serialize/deserialize it to/from XML. java.util.Map
is an interface,
so it does not meet this requirement :-)
If your web service operation is just trying to return (or accept) a
hash map
of "arbitrary complex types", I recommend that you consider switching
this to
be an "array of arrays of specific complex types". The reason I say this
is because,
it allows even non-Java consumers to look at the <schema> elements in
your web
services' WSDL, and figure out all the possible "arbitrary complex types"
that
might be in this array. If you envision the consumer getting a box, where
it can
literally contain anything, you can probably see how much more code they
would
need to write, than if they knew the the box contained a box of these,
and a box
of these, and so on, and so on.
Basically, all the "old school" type-safety rules still apply to web
services
computing. If you want web services with descent performance metrics,
you're probably
going to want to keep a lot of the "old school, distributed computing"
practices
in mind, when you design your stuff :-)
That said, WLS 7.0 SP1 does not currently have a "built-in" HashMap codec.
But,
you could create one using the information at:
http://edocs.bea.com/wls/docs70/webserv/customdata.html#1054435
Regards,
Mike Wooten
"girish" <[email protected]> wrote:
Wonder, how we can return a java.util.Map type from a webservice deployed
on a
weblogic 7.x environment..
any input is appreciated.
-Girish -
Hi Java Team
For a calling a servlet from a HTML form that is placed inside a folder name HTML in the webcontent we need to map the welcome file as
<welcome-file>HTML\Home.html</welcome-file>
In my application I am reading an Excel file to update database
but when i am creating the input stream object i am currently giving the entire path like
FileInputStream f = new FileInputStream("E://sample1/sample1/WebContent/Files/Book10.xls")
is there any mapping which we can do in web.xml by which i need to give only the file name like
FileInputStream f = new FileInputStream ("Book10.xls")
Thanks
SanthoshHi Mark,
I don't think it is possible to nest the XML mapping.
This is because your table data will be just two-dimentional. Through your table return several keywords for each template, the query result will look something like:
template_key id ver keyword
tkey1 INSTLP0001a 1.2 key 1 v1.2
tkey1 INSTLP0001a 1.2 key 2 v1.2
tkey1 INSTLP0001a 1.2 key 3 v1.2
Look at the above exhibit. all the column except keyword are repeated.
So, you can achieve this in two ways.
1. Change your schema to have a one level data mapping.
2. Split your schema into three so that you will have three xml files.
Hope this may help you!
Nith -
Xcelsius Dashboard on SAP R/3 Table using BSP and XML Mapping
Hi Experts,
I have developed a simple dashboard on small data set (10 records) that I am fetching from a R/3 Table into BSP and generating XML from there and consuming it in Xcelsius (SAP R/3 + BSP + XML Mapping).
Now I want to fetch data based on Variables values that should be passed from the dashboard at the runtime and should display the data accordingly. Any help on how it can be achieved?
Thanks..!!
SharadHi,
You could try doing this by using XML data connection. You would have to make use of Enable load to get the data from XML and Enable send to send data back to XML from dashboard.
This would require you to write a script.
Thanks,
Amit -
List View Bound to XML Map Data
HI Have a list view that is bound to xml mapped data. It seems that on connection refresh that new data is not being updated into the SWF. My Binding is directly onto the cell ranges that are mapped into excel, so on updates the size of the maped table changes/rewrites over the old data.
When I refresh I am not picking up the newest data in the list view. Any thoughts on this on how I can fix.
Regards,
MarkThank you Ganesh, but I am not on Enterprise edition. I am successfully bringing in live xml data, however mapping more than one Query result from one xml file is giving my project some problems. Refreshing a list View I think is causing this issue. From within my project in design view I can Refresh the data.
When I publish the file to html/SWF when I refresh other components are refreshing but the list view and one other is not refreshing..... -
Error: java.util.map can not be inherited with different arguments
Hi,
I am getting following error while building the source code.
C:\venus\src\com\martquest\messaging\msgio\MqMessageIOObjectCarrier.java:36: java.util.Map cannot be inherited with different arguments: <> and <java.lang.Object,java.lang.Object>
[javac] public class MqMessageIOObjectCarrier extends Properties implements IMqMessageIOObjectCarrier
What should I do to resolve this issue?
Thanks
PrachiHi,
I am getting following error while building the
source code.whose source code? If it's yours, you'd better look at where you are defining and using Map. The error code tells you exactly what's wrong.
Maybe you are looking for
-
I synchronized my pictures to my ipod using itunes. I connected my ipod to the TV (red to red etc.) using an ipod AV cable. I tried setting the TV to video 1 and also video 2 but got no image on the TV.Is there something I should be doing in the slid
-
If I want to have my component structure have difference cost elements outside the range is that possible? We had cost component 10 assigned to a range of cost elements. Now I want to add an additional cost element to that range, which we did in a s
-
Can i use Indian AppleCare for my Saudi Arabian iPhone 5S?
My dad is getting the iPhone 5S for me from Saudi Arabia.However it's warranty is not valid in India.I plan to get the AppleCare for my iPhone.However I don't know where to buy one.If I buy AppleCare from India,will it work for my Saudi Arabian iPhon
-
Reg Purchase Order Header text
Hi PPL, I have a requirement where in i need to print the Header text that is maintained in a PO in to the Script form.My requirement is that for a specific combination of a Plant and a Vendor i need to populate the Header text automatically on the P
-
Hi, I can not delete files Film / video from the desktop it wants my password I write but Ando I can not float to Trash