JAXB - Java to XML namespaces question

I want the following XML to be produced:
<service
xmlns="http://www.example.org/service"
xmlns:db="http://www.example.org/db"
>
<firstElement>
   <db:title>Testing</db:title>
</firstElement>
</service>However, this is proving to be impossible in JAXB. If I put any namespace within any annotation within my java bean I get unwanted prefixes everywhere. If I use the XmlSchema at the package level and specify prefixes with @XmlNs that doesn't even show up in the XML.
I feel I am almost at a loss?

Well, i got it to work in JAXB 1, w/o xfire, schema-to-java. Marshall and unmarshall.
But w/ xfire, it doesn't appear to be possible. Would probably require implementing it for them myself...

Similar Messages

  • XML Namespace Question

    Hi folks,
    I'm new to XML, and have been trying to validate an XML document against a schema using an online validator.
    I have given ultra-simple examples of my schema and document below:
    Schema
    <?xml version="1.0"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com"
    xmlns="http://www.example.com">
         <xs:element name="letter">
                   <xs:complexType>
                        <xs:sequence>
                             <xs:element name="to" type="xs:string"/>
                             <xs:element name="from" type="xs:string"/>
                        </xs:sequence>
                   </xs:complexType>
         </xs:element>
    </xs:schema>
    Document
    <?xml version='1.0' ?>
    <letter xmlns="http://www.example.com">
              <to>You</to>
              <from>Me</from>
    </letter>When I try to validate the document against this schema I get the following errors:
    Validation error:
    Error at (3,4): The element 'http://www.example.com:letter' has invalid child element 'http://www.example.com:to'. Expected 'to'.
    Error at (3,4): The 'http://www.example.com:to' element is not declared. An error occurred at , (3, 4).<to>You</to>
    Error at (4,4): The 'http://www.example.com:from' element is not declared. An error occurred at , (4, 4).<from>Me</from> </letter>
    I must be doing something wrong when declaring namespaces, but I can't see what. Can anyone point me in the right direction, please?
    Thanks,
    s.

    This is what I have for your code:
    import java.io.IOException;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.w3c.dom.NamedNodeMap;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.xml.sax.helpers.DefaultHandler;
    public class JAXPValidator
         public void validateXML(String XmlDocumentUrl) throws Exception
              System.setProperty( "javax.xml.parsers.DocumentBuilderFactory",
                                       "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
              factory.setNamespaceAware(true);
              factory.setValidating(true);
              factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
                                        "http://www.w3.org/2001/XMLSchema");
              DocumentBuilder builder = factory.newDocumentBuilder();
              Validator handler = new Validator();
              builder.setErrorHandler(handler);
              Document doc = builder.parse(XmlDocumentUrl);
              if( handler.hasValidationError() )
                   throw( handler.getParseException() );
    // these simple loops assume that the xml has already been validated!
              NodeList letters = doc.getElementsByTagName( "letter" );
              for( int i = 0; i < letters.getLength(); i++ )
                   NodeList letterChildren = letters.item( i ).getChildNodes();
                   for( int j = 0; j < letterChildren.getLength(); j++ )
                        Node nextNode = letterChildren.item(j);
                        if( nextNode.getNodeType() == Node.ELEMENT_NODE )
                             Node nextNodeValue = nextNode.getFirstChild();
                             System.out.println( "nextNode.getLocalName() is " + nextNode.getLocalName() );
                             System.out.println( "nextNodeValue.getNodeValue() is " + nextNodeValue.getNodeValue() );
         private class Validator extends DefaultHandler
              private boolean validationError = false;
              private SAXParseException saxParseException = null;
              public boolean hasValidationError()
                   return( validationError );
              public Exception getParseException()
                   return( saxParseException );
              public void error(SAXParseException exception) throws SAXException
                   validationError = true;
                   saxParseException = exception;
              public void fatalError(SAXParseException exception) throws SAXException
                   validationError = true;
                   saxParseException = exception;
              public void warning(SAXParseException exception) throws SAXException
                   validationError = true;
                   saxParseException = exception;
         public static void main(String[] argv)
              JAXPValidator validator = new JAXPValidator();
              try
                   validator.validateXML(argv[0]);
              catch( Exception e )
                   e.printStackTrace( System.err );
    }This was compiled with:
    javac -classpath .;..\xerces-2_7_0\xercesImpl.jar;..\xerces-2_7_0\xml-apis.jar JAXPValidator.javaand run with
    java -classpath .;..\xerces-2_7_0\xercesImpl.jar;..\xerces-2_7_0\xml-apis.jar JAXPValidator sunforum.xmlIt assumes that the XML and XSD that I posted before are in the same directory as the program is being run from.

  • Java Mapping Using JAXB [Java Arch for XML Binding]

    Hi All,
    Anyone tried using JAXB  [Java Architecture for XML Binding API available with Java WebServices Pack] technique for XML processing in Java Mapping??
    I am facing the following problems..
    1. I am not able to generate namespace while marshalling target XML [In standalone mode and not tried in XI].
    2. What are the jar files we need to import?
       I tried importing the following jar files in XI.
    jaxb-api.jar,jaxb-impl.jar,jaxb-libs.jar,jax-qname.jar,namespace.jar,relaxngDatatype.jar
      and getting some errors while importing these files in XI.
    3. It throws error at runtime [Interface Mapping-Test Tab]
       like Resource not found:javax/xml/bind/Messages_en.properties,javax/xml/bind/Messages_en_US.properties
    4. Even after creating a copy of available file Messages.Properties with name: Messages_en.properties and Messages_en_US.properties.. it is not generating any messages in Target message tab
    Thanks in Advance,
    Ananth Chinnaraj

    Sravya ,
    I have searched wide and far for this, but no success.
    A lot on JAXB XI and Webdynpro, but nothing on JAXB, XI and mappings.
    Could you please post the url here ?
    Thanks and kind regards,
    Jan

  • Marshalling Java to XML using JAXB

    Hi,
    I have just downloaded the JAXB reference implementation and have been trying out marshalling Java objects to XML.
    I have a very basic question - can I convert the data from my Java classes into XML and simply send it as a String to another object instead of only having to write it out into a File? Ideally, I want to convert Java to XML from my Business Layer and send XML to my Presentation Layer objects. To do this, I need the XML returned to me in the form of a String and not a File. Any tips will be highly appreciated.

    You should be using Object Factory. JAXB provides one ObjectFactory for each schema.
    Create that particular object and after filling values into that object please set it to the Jaxb object where ever it fits.
    Like
    <Message>
    <Type></Type>
    <Name></name>
    <Message>
    If you want to set Name then JAXB will provide you with setter which be used to set or get. Util you are setting an object which is can repeat more that once then you will have to get a list from the JAXB object and add those objects into the list which will automatically add it the main object.

  • JAXB 1: is it possible to go from enum simulation in Java to XML Schema?

    I know how to get an enum simulation in java from XML schema, but can it be done in the other direction, in the context of a web service implementation?
    The thing is from schema to java a customization file is used. But there's no specification for such a customization file usability when going from java to schema. So far, i'm getting a string for enum wrapper.

    Well, i got it to work in JAXB 1, w/o xfire, schema-to-java. Marshall and unmarshall.
    But w/ xfire, it doesn't appear to be possible. Would probably require implementing it for them myself...

  • Javax.servlet.ServletException: The name "" is not legal for JDOM/XML namespaces

    Dear all,
    First of all sorry, if this is not the right place for my question.
    I am facing some problem with the XFire Webservices. When i am trying to access the WSDL through the url. server is throwing the following exception :
    javax.servlet.ServletException: The name "" is not legal for JDOM/XML namespaces: Namespace URIs must be non-null and non-empty Strings.
         org.codehaus.xfire.transport.http.XFireServletController.doService(XFireServletController.java:143)
         org.codehaus.xfire.transport.http.XFireServlet.doGet(XFireServlet.java:107)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    root cause
    org.jdom.IllegalNameException: The name "" is not legal for JDOM/XML namespaces: Namespace URIs must be non-null and non-empty Strings.
         org.jdom.Namespace.getNamespace(Namespace.java:164)
         org.codehaus.xfire.util.NamespaceHelper.getUniquePrefix(NamespaceHelper.java:58)
         org.codehaus.xfire.aegis.type.basic.BeanType.writeSchema(BeanType.java:560)
         org.codehaus.xfire.wsdl.AbstractWSDL.addDependency(AbstractWSDL.java:224)
         org.codehaus.xfire.wsdl.AbstractWSDL.addDependency(AbstractWSDL.java:233)
         org.codehaus.xfire.wsdl11.builder.WSDLBuilder.createDocLitPart(WSDLBuilder.java:403)
         org.codehaus.xfire.wsdl11.builder.WSDLBuilder.createPart(WSDLBuilder.java:355)
         org.codehaus.xfire.wsdl11.builder.WSDLBuilder.writeParameters(WSDLBuilder.java:509)
    cont.......
    I am not able to figure out the root cause for this. The service.xml file looks like below:
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- START Service.xml -->
    <beans xmlns="http://xfire.codehaus.org/config/1.0">
    <!-- Construct the castor service factory by Spring -->
    <bean id="castorTypeRegistry" class="org.codehaus.xfire.castor.CastorTypeMappingRegistry"/>
    <bean id="bindingProvider" class="org.codehaus.xfire.aegis.AegisBindingProvider">
    <constructor-arg ref="castorTypeRegistry"/>
    </bean>
    <bean id="castorServiceFactory" class="org.codehaus.xfire.service.binding.ObjectServiceFactory">
    <constructor-arg index="0" ref="xfire.transportManager"/>
    <constructor-arg index="1" ref="bindingProvider"/>
    </bean>
    <service>
    <name>ReleaseManager</name>
    <namespace>ReleaseManager</namespace>
    <serviceClass>com.pinkroccade.jfoundation.calculation.releases.ReleaseManager</serviceClass>
    <implementationClass>com.pinkroccade.jfoundation.calculation.releases.ReleaseManagerImpl</implementationClass>
    <schemas>
    <schema>META-INF/schema/release-impact-worksheet-3.2.0.xsd</schema>
    </schemas>
    <style>document</style>
    <serviceFactory>#castorServiceFactory</serviceFactory>
    </service>
    </beans>
    <!-- END Service.xml-->
    The issue which i am facing is it due to the problem with the service.xml (Which i dont think so..), Or is it any thing to do with the XSD file which i am using.
    Can any body give me some guide lines for this ????
    Thanks in advance.
    Thanks and Regards,
    Manjunath.

    Any one any thoughts..
    I need to find out the solution for this as soon as possible; Not able to proceed further...
    Thanks and Regards,
    Manjunath.

  • Basic namespace question

    Hello,
    A (possibly dumb) namespace question - a schema that we are coding against has the following declaration:
    <xs:schema xmlns="http://webservices.myco.com/mycoXML/2003/07" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://webservices.myco.com/mycoXML/2003/07" elementFormDefault="qualified">When this schema is xjc'ed and then the associated java objects populated, then marshalled into an xml request, it prefixes "ns2" to all the elements within the XML, possibly because there are 2 namespaces specified.
    the web service however throws a "Could not find element" error, because it's not expecting the ns2 prefix.
    The questions are:
    1. could this ns2 be suppressed?
    2. does it make sense to suppress it?
    any other background/info about this and the right way to resolve it would be greatly appreciated.
    [edit]
    I may have a partial answer to my question - w3.org's primer told me that since the elementFormDefault is set to qualified, and attributeFormDefault is (by default) unqualified, it uses the ns2 to differentiate between the two.
    when i added attributeFormDefault="qualified", it prefixed everything with an ns1, which the web service seems to be quite happy with.
    if anyone has any other comments/insights, i'd appreciate it.
    Thanks,
    Nilesh
    Edited by: nthali on Apr 15, 2010 2:04 PM

    Just to add to Tims response
    If you do calc dim on account first and then aggregate sparse dimensions, then its best to Fix on Level 0 of all the Sparse dimensions for the calc dim and then aggregate the sparse. Otherwise when you run the calc the second time the calculation will calc dim on all levels of all sparse dimension combinations (there will be data there from the previous aggregation). This can be very very slow. So see below
    FIX("Local", "HSP_InputValue", "Actual",  "Final", "Jan", "FY15")
      FIX(@RELATIVE("Entity",0),@RELATIVE("Product",0), @RELATIVE("Channel",0),@RELATIVE("Project",0))
    CALC DIM ("Account");
    ENDFIX
    AGG ("Entity","Product", "Channel", "Project",);
    ENDFIX;

  • Issue with XML namespace and Message structure

    Hi All,
    I am using Oracle SOA Suite 11.1.1.4. I have SOA web service application one-way messaging wherein I keep receiving messages from the third party. The issue I am facing is with the XML namespaces which conflicts with the third party's message structure. The details are as below.
    Our Web-service WSDL*
    <schema attributeFormDefault="unqualified" elementFormDefault="qualified"
    targetNamespace="http://amb.com/cad/RealTimeService"
    xmlns:cad="http://amb.com/cad/RealTimeService"
    xmlns:avl="http://schemas.com/asiapac/cad/datamodel/avl/1.0.0"
    xmlns:evn="http://schemas.com/asiapac/cad/datamodel/event/1.0.0"
    xmlns:uni="http://schemas.com/asiapac/cad/datamodel/unit/1.0.0"
    xmlns:dvt="http://schemas.com/asiapac/cad/datamodel/divert/1.0.0"
    xmlns:sui="http://schemas.com/asiapac/cad/datamodel/suppinfo/1.0.0"
    xmlns="http://www.w3.org/2001/XMLSchema">
    <import namespace="http://schemas.com/cad/datamodel/avl/1.0.0"
    schemaLocation="AvlCadSchema.xsd"/>
    <import namespace="http://schemas.com/cad/datamodel/unit/1.0.0"
    schemaLocation="UnitCadSchema.xsd"/>
    <import namespace="http://schemas.com/cad/datamodel/event/1.0.0"
    schemaLocation="EventCadSchema.xsd"/>
    <import namespace="http://schemas.com/cad/datamodel/divert/1.0.0"
    schemaLocation="HewsCadSchema.xsd"/>
    <import namespace="http://schemas.com/cad/datamodel/suppinfo/1.0.0"
    schemaLocation="SupplementalInformationCadSchema.xsd"/>
    <element name="AvlAuxData" type="avl:AvlAuxData" nillable="true"/>
    <element name="AgencyEvent" type="evn:AgencyEvent"/>
    <element name="Diversion" type="dvt:HospitalDiversionMessage"/>
    <element name="SupplementalInformation" type="sui:SupplementalInformation"/>
    <element name="UnitDetail" type="uni:UnitDetail"/>
    </schema>
    Using SOAP UI tool a HospitalDiversionMessage Request for the above WSDL will look like*
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:real="http://amb.com/cad/RealTimeService" xmlns:ns="http://schemas.com/cad/datamodel/divert/1.0.0">
    <soapenv:Header/>
    <soapenv:Body>
    <*real*:Diversion>
    <ns:Action>?</ns:Action>
    <ns:Open>?</ns:Open>
    <!--Optional:-->
    <ns:Location>?</ns:Location>
    <ns:Type>?</ns:Type>
    <ns:SubType>?</ns:SubType>
    <!--Optional:-->
    <ns:ExpiryTimestamp>?</ns:ExpiryTimestamp>
    <!--Optional:-->
    <ns:Comment>?</ns:Comment>
    <!--Optional:-->
    <ns:ItemNumber>?</ns:ItemNumber>
    <!--Optional:-->
    <ns:Notifications>?</ns:Notifications>
    <ns:CreatedTerminal>?</ns:CreatedTerminal>
    <ns:CreatedTimestamp>?</ns:CreatedTimestamp>
    <!--Optional:-->
    <ns:ClosedBy>?</ns:ClosedBy>
    <!--Optional:-->
    <ns:ClosedComments>?</ns:ClosedComments>
    <!--Optional:-->
    <ns:ClosedTerminal>?</ns:ClosedTerminal>
    <!--Optional:-->
    <ns:ClosedTimestamp>?</ns:ClosedTimestamp>
    </real:Diversion>
    </soapenv:Body>
    </soapenv:Envelope>
    Now the third party sends a HospitalDiversionMessage in this format_
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="http://amb.com/cad/RealTimeService" xmlns:ns="http://schemas.com/cad/datamodel/divert/1.0.0">
    <soapenv:Header/>
    <soapenv:Body>
    <ns0:Diversion>
    <ns0:Action>?</ns0:Action>
    <ns0:Open>?</ns0:Open>
    <!--Optional:-->
    <ns0:Location>?</ns0:Location>
    <ns0:Type>?</ns0:Type>
    <ns0:SubType>?</ns0:SubType>
    <!--Optional:-->
    <ns0:ExpiryTimestamp>?</ns0:ExpiryTimestamp>
    <!--Optional:-->
    <ns0:Comment>?</ns0:Comment>
    <!--Optional:-->
    <ns0:ItemNumber>?</ns0:ItemNumber>
    <!--Optional:-->
    <ns0:Notifications>?</ns0:Notifications>
    <ns0:CreatedTerminal>?</ns0:CreatedTerminal>
    <ns0:CreatedTimestamp>?</ns0:CreatedTimestamp>
    <!--Optional:-->
    <ns0:ClosedBy>?</ns0:ClosedBy>
    <!--Optional:-->
    <ns0:ClosedComments>?</ns0:ClosedComments>
    <!--Optional:-->
    <ns0:ClosedTerminal>?</ns0:ClosedTerminal>
    <!--Optional:-->
    <ns0:ClosedTimestamp>?</ns0:ClosedTimestamp>
    </ns0:Diversion>
    </soapenv:Body>
    </soapenv:Envelope>
    Questions*
    1) I cannot figure out how the SOAPUI tool or SOA substitutes "real" as the namespace prefix for the WSDL based HospitalDiversionMessage and what I need to do at my end to match the message structure as per what the third party needs.
    2) I need ns0 namespace prefix to whole of Diversion xml element. Currently it is "real" at top Diversion element and "ns" for its children
    Please suggest, I can attach the other imported XSD if need be.
    Thanks
    Edited by: user5108636 on Jun 13, 2011 6:55 PM
    Edited by: user5108636 on Jun 13, 2011 6:57 PM
    Edited by: user5108636 on Jun 13, 2011 7:02 PM

    Questions
    1) I cannot figure out how the SOAPUI tool or SOA substitutes "real" as the namespace prefix for the WSDL based HospitalDiversionMessage and what I need to do at my end to match the message structure as per what the third party needs.The xml namespace suffixes like real and ns0 are just references used by the XML Parsers. For that matter the "real" can be xyz as well.
    You dont need to make any changes as long as the xml namespace suffixes refer to the same namespace.
    If you see the first soapUI xml and the third party xml have the same namespace references and hence it is not a problem:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:real="*http://amb.com/cad/RealTimeService*" xmlns:ns="http://schemas.com/cad/datamodel/divert/1.0.0">
    <soapenv:Header/>
    <soapenv:Body>
    <*real*:Diversion>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="*http://amb.com/cad/RealTimeService*" xmlns:ns="http://schemas.com/cad/datamodel/divert/1.0.0">
    <soapenv:Header/>
    <soapenv:Body>
    <*ns0*:Diversion>
    2) I need ns0 namespace prefix to whole of Diversion xml element. Currently it is "real" at top Diversion element and "ns" for its childrenBased on this, logically both the xmls represent the same xml message. And hence you dont need to make any changes.
    Please refer to the basics of xml namespaces using the following links:
    http://en.wikipedia.org/wiki/XML_namespace
    http://zvon.org/comp/r/tut-Namespace.html#Pages~Introduction
    Let us know if you still need clarification.
    Hope this helps.
    Thanks,
    Patrick

  • Xml namespace and xslt

    Hi,
    This is a pure xml question. Let me know if there are good forums better suited for this kind of problem.
    I receive an xml message with the following format:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <staticMessage xmlns="Static/nme" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="Static/nme ./StaticMessage.xsd">
    </staticMessage>I fail to apply transformation when using a stylesheet like:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
         <xsl:value-of select="staticMessage/body/data"/>
    </xsl:template>
    </xsl:stylesheet>However if I remove the xmlns attribute in the incoming message (xmlns="Static/nme" ) the transformation works correctly.
    I do not have a great understanding of namespaces.
    Does anyone know if any special declaration needs to be made for the xsl file to work correctly?
    Tx,
    Mik.

    Noticed that declaring a prefix in xsl (xmlns:pre="Static/nme") allows to access nodes or values ( pre:staticData/pre:.../)
    But does a prefix need to reference the xml namespace or is it possible to define it as default?
    Tx,
    Mik.

  • XML Namespace in WebService Request/Response

    Hi all,
    I have a question regarding xml namespace usage in wsdl and the corresponding request/response messages.
    I have already browsed quite some articles about xml namespaces as well as some forum threads, but I am still not sure.
    I have the following part of a wsdl document (generated by Integration Directory), defining a targetnamespace.
    u2026
    <wsdl:types>
        <xsd:schema targetNamespace="http://www.dorma.com/sap/xi/finance"
                             xmlns="http://www.dorma.com/sap/xi/finance"
                             xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <xsd:element name="DebtorGetDetailResponse" type="Z_BAPI_DEBTOR_GETDETAIL_Response"></xsd:element>
            u2026
            <xsd:complexType name="Z_BAPI_DEBTOR_GETDETAIL_Response">
                <xsd:sequence>
                    <xsd:element name="DEBITOR_COMPANY_DETAIL" type="BAPI1007_5" minOccurs="0">
                    </xsd:element> u2026
                </xsd:sequence>
            </xsd:complexType>
            u2026
        </xsd:schema>
        u2026
    </wsdl:types>
    u2026
    In my understanding, all types defined in the schema section of a wsdl document will be in the targetnamespace, if defined.
    Therefore the element DEBITOR_COMPANY_DETAIL would be in the namesapce
    http://www.dorma.com/sap/xi/finance
    However, the ABAP proxy generates a response message like follows,
    where only the root element is in this namespace and the child elements are in the global namespace:
    <?xml version="1.0" encoding="utf-8"?>
    <ns1:DebtorGetDetailResponse xmlns:ns1="http://www.dorma.com/sap/xi/finance"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <DEBITOR_COMPANY_DETAIL>
            u2026
        </DEBITOR_COMPANY_DETAIL>
        u2026
    </ns1:DebtorGetDetailResponse>
    Do I have a wrong understand of the wsdl (xml schema) or is this an erroneous behavior?
    The problem is that some 3rd-party software web service module does not accept
    the response message as not complient with the respective wsdl document.
    Any input is appreciated.
    Thanks
    Hans
    Edited by: Hans-Jürgen Schwippert on Oct 1, 2008 12:02 PM

    I have the same problem. I am trying to connect to a webservice running on IBM websphere but it doesn't accept the xml in my request. It appears to be the same namespace issue.
    Did you ever find a solution for this?
    Is it a valid webservice call if you omit the namespace for an element or is this a bug in the Adaptive WS implementation?
    Web Dynpro web service model generated request:
    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SOAP-ENV:Header>
    <sapsess:Session xmlns:sapsess="http://www.sap.com/webas/630/soap/features/session/">
    <enableSession>true</enableSession>
    </sapsess:Session>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
    look between these lines -
    <ns1:tamKontrolleraKontoLastAnrop xmlns:ns1="http://schemas.fora.se/modell/tam/1.0/TAM_Data">
    <AnvandarNamn>30039647</AnvandarNamn>
    </ns1:tamKontrolleraKontoLastAnrop>
    look between these lines -
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    As you can see the tag
    <AnvandarNamn>30039647</AnvandarNamn>
    is missing a namespace.
    It should be
    <ns1:AnvandarNamn>30039647</ns1:AnvandarNamn>
    Using a third part tool called Soapui i generate this request that works:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tam="http://schemas.fora.se/modell/tam/1.0/TAM_Data">
       <soapenv:Header/>
       <soapenv:Body>
          <tam:tamKontrolleraKontoLastAnrop>
             <tam:AnvandarNamn>30039647</tam:AnvandarNamn>
          </tam:tamKontrolleraKontoLastAnrop>
       </soapenv:Body>
    </soapenv:Envelope>

  • XML Namespaces

    Hi Friends,
    This question should be asked in any XML forum. But I think I will get good answer from here only.
    Well, the thing is that I am little bit confused about XML Namespaces values. They are just literal string, that's what I currently understand, in terms of URL or URN.
    What I want to know is, can this URL or URN hold the value (string) which is not existing really.
    As an example, is the following URL valid value for Namespace ?
    http://www.abc.efg.ijk/pqr/xyz/Student
    Thanks,
    Bakul.

    Hi,
    I tried to look into the link you mentioned, but it's exhaustive document.
    I just wanted to know that, is it necessary to have URLs or URNs used as namespace, should be registered with some body ?
    If it is like that, then everytime a developer wants to use a namespace, it will have to contact that body and get it registered. That doesnt sound practicle.
    Can you pls help me understand it ??
    Thanks,
    Bakul.

  • Preserving Timezone from Java to XML

    Hi,
    I am writing a web-service for date time functions.
    In the response for my web-service, I will send a time (xsd:time) say 4 PM EST. But when the marshalling happens, the 16:00:00-05:00 is automatically converted to 21:00:00Z. (EST to GMT conversion happends automatically). But i dont want this to happen, the caller should see the timezone I am sending them.
    The xml data type is xsd:time and the corresponding Java Object is java.util.Calendar.
    Is there a way to do this.
    Thanks in advance for your replies.

    VenkyThaniks wrote:
    The xml data type is xsd:time and the corresponding Java Object is java.util.Calendar.This question doesn't appear to be related to Sun Calendar Server.
    I suggest you ask on the java programming forum:
    http://forums.sun.com/forum.jspa?forumID=31
    Regards,
    Shane.

  • Using JAXB to edit XML documents

    I am trying to understand how (and whether) JAXB can be used to make the following types of changes to an existing XML document. I know that I can EDIT an XML document using the set methods that are generated by JAXB (in conformance with the XML Schema), and then I create a Marshaller and marshall the root element object.
    However, I have not figured out how to do any of the following:
    (i) insert a new element
    (ii) delete an existing element
    (iii) reorder elements.
    Here is an excerpt from an XML document:
    <directory name="dir">
    <file name="file1"/>
    <file name="file2"/>
    <file name="file3"/>
    </directory>
    The order in which the file elements appear is significant.
    If I want to add a new file (file4), how would I do this? Where would it be added, at the end? What if I wanted to add it after file2?
    If I want to delete file1, I don't know how to do that.
    Finally, if I want to move file2 after file3, I don't know how to do that.
    It seems as though I need access to the underlying com.sun.xml.bind.util.ListImpl (or similar collection object), which holds the actual file elements when JAXB unmarshals the xml file. However, this seems dangerous and I have gotten a concurrent access exception while trying to do something like this. (Another problem has to do with iterators, where I can't iterate through a list and then make a change to the list w/o messing up the iterator.)
    If there are any technologies other than JAXB that might accomplish this, but that provide data binding, I would be happy to hear about it. (I could try SAX/DOM/JDOM/DOM4J or XSLT, I guess, but I like the data binding of JAXB.)

    As is typical for me, I answered my own questions.
    if you are outside of an iterator, you can simply use the:
    add(object)
    add(position,object)
    remove(object)
    methods of the List interface to add and remove elements from the list of elements.
    Also, if you use a ListIterator, you can call the add() and remove() methods of ListIterator while iterating through the list.
    In order to reorder elements in the list, use:
    Collections.swap(list,pos1,pos2). Why this method is not built into the List interface itself is beyond me. This was only added in 1.4, btw.

  • XML namespace in xml converted pdf

    Hello everyone
    I have a problem when converting pdf's in xml. Everytime when I convert a PDF(either with Acrobat or with mailing the file as XML) in XML the date fields always in middle shows the xml namespace xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" . We are using these xml's to transfer data to an accounting software but the software recognizes the xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" as an error and because of that the data couldn't be uploaded. We created the PDF using a xsd scheme made in the accounting software. Is there a way to get rid of xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" showing in the date fields.
    I appreciate every possible help

    Hi,
    It sounds like you have the nillable="true" attribute in you XSD for the date field.
    If you XSD looks like;
    <xs:element name="Date1" type="xs:date" nillable="true"/>
    Then you will get the following when the field Date1 is bound to is left blank.
    <Date1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
    This is the correct behaviour, so I am either not understanding the problem or there is a bug in the accounting software you are using.
    Maybe you could try replacing the nullable="true" with a minOccurs="0".  This will mean the element will not appear in the XML at all.
    Regards
    Bruce

  • Idoc to XML, namespace is not getting created in output XML

    Hi All
    My interface is idoc to XML.
    I am using graphical message mapping.
    In output xml , namespace is not  formed
    Can any one tell why namespace is not  created in the XML and
    How to add the  namespace to the  output XML .
    Kindly help
    Regards,
    Sheela

    Hi,
    You can change your external definition to achieve it.  just compare the structure of your xsd with some other normal data type xsd and change accordingly.
    Inder

Maybe you are looking for