Constructing soap message using jaxm

Hi all,
I want to constrct a soapmessage using jaxm package.
My code is like below.
DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance( );
DocumentBuilder db = dbf.newDocumentBuilder() ;
File file = new File( "C:/Ramana/hey.xml");
Document doc = db.parse(file);
domsrc = new DOMSource(doc);
soapPart.setContent(domsrc);
message.writeTo(System.out);
I am getting always the following exception..
javax.xml.soap.SOAPException: Unable to get header stream in saveChanges: SOAP exception while trying to externalize: Unable to create envelope from given source: com.sun.xml.messaging.soap.dom4j.ElementImpl
     at com.sun.xml.messaging.soap.MessageImpl.saveChanges(MessageImpl.java:357)
     at com.sun.xml.messaging.soap.MessageImpl.writeTo(MessageImpl.java:396)
I am thankful if any body could help me what the problem is.
thanks in advance,
Ramana

for more information I use the following xml file
<?xml version='1.0' encoding='UTF-8' ?> <library> <!-- the isbn could have been an element --> <book isbn='0-312-85172-3'> <title>Aristoi</title> <author>Walter Jon Williams</author> </book> <book isbn='0-812-51349-5'> <title>Enders Game</title> <author>Orson Scott Card</author> </book> </library>
I also did some tests using some other xml files..
I got the same exception.
Any help is really appreciable.
I heared it can be the problem of name space settings in xml file.
if so?Can u please tell me what should I do?

Similar Messages

  • Http Header for a SOAP message using SAAJ.

    Hello java community,
    I need to set the 'SOAPAction' field in the HTTP Header of a soap message. I am using SAAJ to build the message.
    Does anyone know how to do this?
    Help is greatly appreciated as always.

    You have to put a Handler in front of your WebService to intercept it.

  • SOAP Messaging Using Crystal Reports Web Services To Return Report in PDF or Excel Format

    All,
    I am trying to use SOAP messaging to fetch a Crystal Report through a Managed repository and getting back either a PDF or Excel file. For some reason, any reference to web services on this site I cannot access. Like thread, "Using Web Services on the Crystal Report Server XI to return reports".  Can anyone point in a direction to Web Service Calls API documentation or does this not exist ?????? I would hope this product has this capability.
    Thanks In Advance,
    Tom

    XI Release 2 Service Pack 2 introduced the Business Process BI Web Services, that allow you to retrieve reports using SOAP messaging.
    It's documented here:
    http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/en/WS_SDK/wssdk_portal/doc/wssdk_bpbi_doc.pdf
    Sincerely,
    Ted Ueda

  • Formating WSDL  SOAP  message using external .xsd file

    Hi,
    I am trying to build web service from java method using xml schema in .xsd file to format soap messages. How can I do this? What steps should I take to accomplish this?
    When I tried to do this using wizard for building web service, and map custom java classes to xml schema types , I got generator error: java.util.NoSuchElementException.
    When I managed to generate web service using that custom mappings (without generator error) , I couldn't deploy that service on server. At deploy time i alway get compile error without named source where error is....

    hI,
    How to add the the below soap frame thru XSLT mapping.
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd">
    <SOAP-ENV:Header>
    <eb:MessageHeader xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd" SOAP-ENV:mustUnderstand="1" eb:version="2.0">
    <eb:From>
    <eb:PartyId>0037123456678</eb:PartyId>
    <eb:Role>Sender</eb:Role>
    </eb:From>
    <eb:From>
    <eb:PartyId>NDEAFIHH</eb:PartyId>
    <eb:Role>Intermediator</eb:Role>
    </eb:From>
    <eb:To>
    <eb:PartyId>FI2757800750155448</eb:PartyId>
    <eb:Role>Receiver</eb:Role>
    </eb:To>
    <eb:To>
    <eb:PartyId>OKOYFIHH</eb:PartyId>
    <eb:Role>Intermediator</eb:Role>
    </eb:To>
    <eb:CPAId>yoursandmycpa</eb:CPAId>
    <eb:ConversationId/>
    <eb:Service>Routing</eb:Service>
    <eb:Action>ProcessInvoice</eb:Action>
    <eb:MessageData>
    <eb:MessageId>20081228-010142</eb:MessageId>
    <eb:Timestamp>2008-12-28T01:01:42+03:00</eb:Timestamp>
    <eb:RefToMessageId/>
    <eb:RefToMessageId>XS1027.LPTF82/268</eb:RefToMessageId>
    </eb:MessageData>
    </eb:MessageHeader>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
    <eb:Manifest eb:id="Manifest" eb:version="2.0">
    <eb:Reference eb:id="Finvoice" xlink:href="XS1027.LPTF82/268">
    <eb:Schema eb:location=" http://www.finvoice.info/yrityksen_verkkolasku/ladattavat/Tekniset tiedostot/schemat/Finvoice.xsd" eb:version="2.0"/>
    </eb:Reference>
    </eb:Manifest>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    <?xml version="1.0" encoding="ISO-8859-15"?>
    <!DOCTYPE Finvoice SYSTEM "Finvoice.dtd">
    <?xml-stylesheet type="text/xsl" href="Finvoice.xsl"?>
    Thanks and Regards,
    Hymavathi

  • How to access SOAP message using JAXP and SOAP class?

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder b = factory.newDocumentBuilder();
    FileInputStream fr = new FileInputStream(args[1]);
    Document doc = b.parse(fr);
    Envelope msgEnv = Envelope.unmarshall (doc.getDocumentElement()); <---
    the exception raised:
    java.lang.IllegalArgumentException: Root element of a SOAP message must be: 'htt
    p://schemas.xmlsoap.org/soap/envelope/:Envelope'
    And the xml file is:
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"...>
    </env:Envelope>

    The problem is that your DocumentBuilderFactory is not set to be namespace aware. If add a call to factory.setNamespaceAware(true) that should fix your problem.

  • Transform payload to SOAP message using XSLT

    Hello,
    I'm working with e-invoice for Finland (called Finvoice) and is supposed to send a soap message as a file via file/ftp adapter.
    The output from SAP is an INVOIC idoc that is mapped to a given output structure. This works fine.
    The soap envelope is created via xslt transformation.
    The Envelope is created correctly but I'm struggling with how to add the payload to the message. It needs to look as shown below, (I'm just showing the essential part).
    My problem is that I don't know how to add the doctype part via xslt:
    <?xml version="1.0" encoding="ISO-8859-15"?>
    <!DOCTYPE Finvoice SYSTEM "Finvoice.dtd">
    I get validation errors when adding this in the xsl. The content of the payload looks good.
    Does anyone know how this can be solved?
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
    <eb:Manifest eb:id="Manifest" eb:version="2.0">
    <eb:Reference eb:id="Finvoice" xlink:href="1017000018">
    <eb:schema eb:location="http://www.pankkiyhdistys.fi/verkkolasku/finvoice/finvoice.xsd" eb:version="2.0"/>
    </eb:Reference>
    </eb:Manifest>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    <?xml version="1.0" encoding="ISO-8859-15"?>
    <!DOCTYPE Finvoice SYSTEM "Finvoice.dtd">
    <?xml-stylesheet type="text/xsl" href="Finvoice.xsl"?>
    <Finvoice Version="1.2">
    <SellerPartyDetails>
    <SellerPartyIdentifier>SellerPartyIdentifier23456789012345</SellerPartyIdentifier>
    <SellerOrganisationName>SellerOrganisationName3456789012345</SellerOrganisationName>
    // Best regards Hans

    hI,
    How to add the the below soap frame thru XSLT mapping.
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd">
    <SOAP-ENV:Header>
    <eb:MessageHeader xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd" SOAP-ENV:mustUnderstand="1" eb:version="2.0">
    <eb:From>
    <eb:PartyId>0037123456678</eb:PartyId>
    <eb:Role>Sender</eb:Role>
    </eb:From>
    <eb:From>
    <eb:PartyId>NDEAFIHH</eb:PartyId>
    <eb:Role>Intermediator</eb:Role>
    </eb:From>
    <eb:To>
    <eb:PartyId>FI2757800750155448</eb:PartyId>
    <eb:Role>Receiver</eb:Role>
    </eb:To>
    <eb:To>
    <eb:PartyId>OKOYFIHH</eb:PartyId>
    <eb:Role>Intermediator</eb:Role>
    </eb:To>
    <eb:CPAId>yoursandmycpa</eb:CPAId>
    <eb:ConversationId/>
    <eb:Service>Routing</eb:Service>
    <eb:Action>ProcessInvoice</eb:Action>
    <eb:MessageData>
    <eb:MessageId>20081228-010142</eb:MessageId>
    <eb:Timestamp>2008-12-28T01:01:42+03:00</eb:Timestamp>
    <eb:RefToMessageId/>
    <eb:RefToMessageId>XS1027.LPTF82/268</eb:RefToMessageId>
    </eb:MessageData>
    </eb:MessageHeader>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
    <eb:Manifest eb:id="Manifest" eb:version="2.0">
    <eb:Reference eb:id="Finvoice" xlink:href="XS1027.LPTF82/268">
    <eb:Schema eb:location=" http://www.finvoice.info/yrityksen_verkkolasku/ladattavat/Tekniset tiedostot/schemat/Finvoice.xsd" eb:version="2.0"/>
    </eb:Reference>
    </eb:Manifest>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    <?xml version="1.0" encoding="ISO-8859-15"?>
    <!DOCTYPE Finvoice SYSTEM "Finvoice.dtd">
    <?xml-stylesheet type="text/xsl" href="Finvoice.xsl"?>
    Thanks and Regards,
    Hymavathi

  • Could not access SOAP header - sending sopa message using weblogic

    i am using saaj to send a SOAP message ,through weblogic, i am getting an error like below
    Could not access SOAP header
    what should i do for sending a soap message using weblogic

    You're going to have to provide many more details than that. If it's useful, you could go here and read all the documentation books covering web services.

  • Outbound SOAP Message with Attachment

    The requirement is to invoke a web service by sending attachments in the outbound SOAP message. The attachment body needs to be assigned in the message flow, using an element E1 extracted from the message incoming into the flow.
    I am trying to use attachments variable to set content-type (text/xml) and body using E1. However, these are not getting assigned to attachments variable, as seen by logging the variable.
    I was told that $attachments cannot be changed inside the flow (it is marked black in the console unlike the header and body that are marked green). If that is the case, how do we invoke services using attachments from a message flow?
    Any pointers would be appreciated.

    Hi,
    A SOAP message may need to be transmitted together with attachments of various sorts, ranging from facsimile images of legal documents to engineering drawings. Such data are often in some binary format. For example, most images on the Internet are transmitted using either GIF or JPEG data formats. In this document we describe a standard way to associate a SOAP message with one or more attachments in their native format in a multipart MIME structure for transport.
    yes it is possible to send attachment with the SOAP.
    SOAP Message Packages
    A "SOAP message package" contains a primary SOAP 1.1 message. It may also contain additional entities that are not lexically within the SOAP message but are related in some manner. These entities may contain data in formats other than XML. The primary SOAP 1.1 message in a message package may reference the additional entities. Such additional entities are often informally referred to as "attachments." This section describes how to construct SOAP message packages and how SOAP processors will process them.
    A SOAP message package is constructed using the Multipart/Related media type, which is defined in RFC 2387. The rules for the construction of SOAP message packages are as follows:
    The primary SOAP 1.1 message must be carried in the root body part of the Multipart/Related structure. Consequently the type parameter of the Multipart/Related media header will always equal the Content-Type header for the primary SOAP 1.1 message, i.e., text/xml.
    The MIME Multipart/Related encapsulation of a SOAP message is semantically equivalent to a SOAP protocol binding in that the SOAP message itself is not aware that it is being encapsulated. That is, there is nothing in the primary SOAP message proper that indicates that the SOAP message is encapsulated .
    For more details you can refer these links
    http://www.w3.org/TR/SOAP-attachments
    http://www.w3.org/TR/soap12-af/
    regards
    Aashish Sinha
    PS : reward points if helpful

  • Soap message with Attachment

    Hi All,
    I have a requirement wherin I have to send an attachment(image) along with the soap payload.i.e. the soap message contains the payload and an attachment.For eg. the soap message is as shown below:
    <?xml version="1.0" encoding="UTF-8" ?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
      <SOAP-ENV:Body>
        <ns1:MT_Soap xmlns:ns1="http://www.adc.com/sample">
             <Record>
                <FieldXML>abc</FieldXML>
                <FieldAthmt />
             </Record>
          </ns1:MT_Soap>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    How can I include the attachment(which is on a local machine) in the above soap message?
    Is it posssible to send the attachment in the field "FieldAtthmt"?
    If it is possible to send an attachment with the soap message then how can that attachment be handled in XI?
    Thanks in advance,
    Vikram

    Hi,
    A SOAP message may need to be transmitted together with attachments of various sorts, ranging from facsimile images of legal documents to engineering drawings. Such data are often in some binary format. For example, most images on the Internet are transmitted using either GIF or JPEG data formats. In this document we describe a standard way to associate a SOAP message with one or more attachments in their native format in a multipart MIME structure for transport.
    yes it is possible to send attachment with the SOAP.
    SOAP Message Packages
    A "SOAP message package" contains a primary SOAP 1.1 message. It may also contain additional entities that are not lexically within the SOAP message but are related in some manner. These entities may contain data in formats other than XML. The primary SOAP 1.1 message in a message package may reference the additional entities. Such additional entities are often informally referred to as "attachments." This section describes how to construct SOAP message packages and how SOAP processors will process them.
    A SOAP message package is constructed using the Multipart/Related media type, which is defined in RFC 2387. The rules for the construction of SOAP message packages are as follows:
    The primary SOAP 1.1 message must be carried in the root body part of the Multipart/Related structure. Consequently the type parameter of the Multipart/Related media header will always equal the Content-Type header for the primary SOAP 1.1 message, i.e., text/xml.
    The MIME Multipart/Related encapsulation of a SOAP message is semantically equivalent to a SOAP protocol binding in that the SOAP message itself is not aware that it is being encapsulated. That is, there is nothing in the primary SOAP message proper that indicates that the SOAP message is encapsulated .
    For more details you can refer these links
    http://www.w3.org/TR/SOAP-attachments
    http://www.w3.org/TR/soap12-af/
    regards
    Aashish Sinha
    PS : reward points if helpful

  • How to parse a entire SOAP Message

    It seems that there is no API in JAXM for parse a entire SOAP Message.
    And how to set encoding of a SOAP Message?

    I can use Apache SOAP for parsing before. There is a class named
    Envelope that has a method unmarshall(Element). So I can parse
    SOAP message as a common DOM, then change to SOAP Message
    using unmarshall. But in JAXP/JAXM, there is no such a class to work.

  • How to send a signed SOAP message with additional HTTP Header fields

    Our Partner's integration requirements are that we send them asynchronous SOAP messages, that are digitally signed, and whose HTTP headers contains 5 or 6 additional header fields, of which 3 or 4 will need to be dynamically set during the message mapping.  I believe we can use the HTTP adapter for adding new fields to the HTTP header, but don't believe it supports signing.  I believe that the SOAP adapter supports signing, but I'm not clear on how to use it to add fields to the HTTP header.  What is the most straight-forward way to achieve both the signing of the message and the addition of the HTTP header values?
    Thanks,
    Kurt

    >>>What is the most straight-forward way to achieve both the signing of the message and the addition of the HTTP header values?
    Use Java mapping for both.
    1) Signing the message
    You can digitally sign the soap message using many standard api like WSS4j? or  refer Java XML signature API which comes in Jdk1.6.
    Refer these links
    WSS4J  -  http://ws.apache.org/wss4j/axis.html
    Java XML signature : http://java.sun.com/developer/technicalArticles/xml/dig_signature_api/
    2) >>whose HTTP headers contains 5 or 6 additional header fields, of which 3 or 4 will need to be dynamically set during the message mapping
    Use Dynamic configuration API to set the additional header fields during message mapping.

  • Modify SOAP message

    Is there any tool which can help me to modify the SOAP response before sending back to the client. I have used tools like tcpmon which just shows the traffic, but I can't modify the message with this.
    Thanks
    Sanat

    forumKid2 wrote:
    user575089 wrote:
    Can a JAX-WS handler alter SOAP message ? In other words, can we modify the SOAP message using JAX-WS handler ?
    Yes.
    Thanks

  • How to create soap message through java using JAXM

    Hi,
    I'M REALLY NEW TO THIS JAVA WEB SERVICES. I need to send a soap messages from core java with using url and it goes to my servlet and able to retrieve the soap message and do the processing. I really don't the work flow too. I'm using JAXM for receiving and transfering message. Could anyone tell me how its going to work for core java. Actually i need to accept any incoming soap messages and according to the request i got , i do need to do the further processing and again send back response to the core java. I'm not sure what i'm telling is wright or wrong. I literally confused with whole java web services . Could anyone help me out please or suggest some other suggestions through which i can proceed further.
    in advance thanks a lot.......

    File f = new File("c:\MyFolder");
    f.mkdir();

  • Problem: Applets cannot Create SOAP Message Objects using JAX Pack

    Hi all
    I want to invoke a simple webservice located at a url.
    I wish to send a SOAP Message . The Message is creating using
    javax.xml.soap package
    Here is the code
    public void init(){
    try{
    MessageFactory MF = MessageFactory.newInstance();
    SOAPMessage message = MF.createMessage();
    SOAPPart SP = message.getSOAPPart();
    SOAPEnvelope SE = SP.getEnvelope();
    SOAPHeader SH = SE.getHeader();
    SOAPBody SB = SE.getBody();
    Name bodyName = SE.createName
    ("testString","L","http://tempuri.org/");
    SOAPBodyElement SBE = SB.addBodyElement(bodyName);
    }catch(Exception e){}
    When I run the applet in a browser I am getting ExceptionInInitializerError or NullPointer Exception.
    The same application works when i run as a standalone application. But not in APPLET.
    Can somebody help me in this regard

    Im trying to do the same thing !!, i have a servlet that processes SOAP messages, and return SOAP messages back.
    Like you i have a implementation running with a stand alone client instead of an applet, which runs fine (there are several .jar files that have to be included in the jre/lib/ext directory, in total about a meg!).
    Im now looking to incorporate this client into an applet, but it moans about cannot find classes (the JAXM and SOAP classes).
    Have you found a solution to this yet ?? Surely you cannot expect the user to download all the required jar files along with the applet??
    With regards to your problem try setting up a button that fires off the SOAP Msg and processes the response, i read on the Sun Java Applet tutorials that some code should stay out of the init method(its a bit vague about WHAT should stay out..), maybe this is an example.
    Thanks,
    (i dont really expect a response as you posted this ages ago !!, but it would be nice.)

  • Asynchronous messaging using SOAP

    Hi,
    Does anybody have experiences using SOAP for asynchronous communications
    like notifications. Is there any way to integrate SOAP with JMS. I would
    appreciate any thoughts / feedback on this.
    Thanks
    Chandra.

    Sorry, I know this is not an answer to your question. I fooled around with JAXM for a while and gave up when I realized it was getting me nowhere. The more I investigated ebXML the more frustrated I became with JAXM.
    I've posted this several times before, but JAXM is absolutely the wrong solution for implementing ebXML. The protocols are in conflict with each other. Sybase provides a true ebXML server and has an outdated, but good, open source toolkit. In addition, Sun has a "technology preview" for what looks to be a server that fully supports ebXML. See http://lists.ebxml.org/archives/ebxml-dev/200210/msg00015.html.
    JAXM only supports parts of the ebXML Message Handling piece. It does not allow the client to dictate whether the conversation is synchronous or asynchronous as ebXML does. JAXM doesn't support using CPA's. In short, you can create messages with JAXM that look like ebXML but aren't.

Maybe you are looking for