How to make a SOAP message?

Hi!
I'm trying to send an object to a JMS queue using SOAP and Spring Integration. I already made the object into XML like so:
<app:MyClass>
  <app:myValue>A value</app:myValue>
</app:MyClass>But I can't figure out how to wrap this into a SOAP message in a satisfying way. I tried using the SOAPMessage class, but since Spring doesn't like sending the message object as-is, I first have to convert it to a String:
//Create message
MessageFactory messageFactory = MessageFactory.newInstance();
soapMessage = messageFactory.createMessage();
//Get parts
SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();
//Insert content
body.addTextNode(myClassXMLString);
soapMessage.saveChanges();
//Convert message to String
ByteArrayOutputStream stream = new ByteArrayOutputStream();
soapMessage.writeTo(stream);
String string = new String(stream.toByteArray());That produces an output that look something like this:
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Header/><env:Body>&#38lt;?xml version="1.0" encoding="UTF-8"?&#38gt;&#38#13;
&#38lt;app:MyClass xmlns:app="http://namespace.myurl.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&#38gt;&#38#13;
   &#38lt;app:myValue&#38gt;A value&#38lt;/app:myValue&#38gt;&#38#13;
&#38lt;/app:MyClass&#38gt;&#13;
</env:Body></env:Envelope>So I have to do some string editing to make it look proper and fix the tags. But at that point I might as well just add the Envelope and other SOAP tags manually with a StringBuilder.
Is there a better way to do this?

I don't know much about SOAP, but I would suggest that if you don't want that data to be handled as text, then you shouldn't be using the addTextNode() method. And working backwards, you shouldn't be converting your data to XML text like that either. Probably you should be doing something else to add the object directly into the SOAP document, but as I say I don't know much about SOAP so I can't say what.
But I would expect any decent SOAP tutorial to have an example of how to put an object into a SOAP document.

Similar Messages

  • How to make numbers in message text input  fields left aligned?

    Hi Friends
    I have completed one of my task .but getting result right side of the field.
    how to make numbers in message text input  fields left aligned?
    Thanks
    Aravinda

    Hi ,
    Sorry for late replay i am trying this alos not set that page....
    pageContext.forwardImmediatelyToCurrentPage(null, true, null);
    and one more that kff field working is fine for ex display any text pled displayed properly and only problem is not set the value and HrSitKeyFlex6 and HrSitKeyFlex7 fields are perfectly get the values but not pront HrSitKeyFlex8 that only my issue....
    Regards,
    Srini

  • How to send a SOAP message with attachments

    How to send a SOAP message with attachments thru webservice using axis-1_3 can any one sujjest.............................

    Please refer
    http://www.javaworld.com/javaworld/jw-09-2003/jw-0912-webservices.html
    http://xml.sys-con.com/read/40315.htm

  • How to get full SOAP message in WebService

    hi,
    Is it possible to get SOAP message while Request operation during transaction in WebService.
    I tried with Handler, while retreiving message it is having a MessageContext. How to initilize that like example
    public boolean handleRequest(MessageContext mc) {
              SOAPMessageContext messageContext = (SOAPMessageContext) mc; 
              System.out.println("** Request: "+ messageContext.getMessage().toString());
              return true;
         }while i make a class called SoapHdlr i have implemented all methods including the above.
    In that from my class if i want to call the above method i need to pass MessageContext how to give that MessageContext or any other ways to get SOAPMessage fully.
    plz can any one guide me there
    ThanKQ

    I think, there are some concepts missunderstood. First if you use JAX-WS- Metro framework, this kind of handlers will work. Also you should identify your SOAPHandler for your web service. For ex: in Netbeans 6, you can right click on service and select configure handlers. Then you decide your handler.
    Then automatically, Metro framework directs SOAPMessages to your SOAPHandler to handle full SOAPs. HandleMessage() method will work.
    If you have problem again, just ask.

  • How to make a SOAP call using the PI 7.1

    Hi All,
    Can you please tell me how can we make a SOAP call using the PI 7.1?
    Thanks in advance

    Hello Shweta,
    Could you please clarify your question? Do you mean you need to call some business system from PI via SOAP? Or do you need to test integration model using SOAP client?
    If the requirement is to make a SOAP call to PI (send SOAP request to PI system), please refer to the guide which Stefan suggested in his post. The general procedure is the following:
    1. generate concrete WSDL in PI (you can do it via PI's Integration Directory);
    2. import generated WSDL to SOAP client (e.g. XML Spy described in the guide or soapUI which is free SOAP client);
    3. create SOAP request message in the SOAP client and send it to the endpoint (in this case, it will be sent to PI).
    This is general procedure for making SOAP calls to SAP PI using external SOAP clients. Please advise if specified steps should be described in more details or if there are any questions from your side regarding them.
    If the question is about calling business system from PI via SOAP, then please refer to SAP Help, configuration of SOAP receiver::
    http://help.sap.com/saphelp_nw04/helpdata/en/29/5bd93f130f9215e10000000a155106/frameset.htm
    My regards,
    Vadim

  • Help, how to monitor the soap message sent by JAX-WS

    Hi,everyone:
    I want to monitor the soap message sent by JAX-WS using apache TCPMon.
    For example, the JAX-WS is deployed on port 8080 , I make TCPMon listening on port 4444 and send soap request to port 4444 using JAX-WS.
    Code in client:
    @WebServiceClient(name = "JAX_WS", targetNamespace = "http://www.example.org/JAX_WS/", wsdlLocation = "file:/E:/zwz/EclipseWorkspace/JAX_WSDemo/WebRoot/META-INF/JAX_WS.wsdl")
    public class JAXWS_Service extends Service {
         private final static URL JAXWS_WSDL_LOCATION;
         private final static Logger logger = Logger
                   .getLogger(demo.client.JAXWS_Service.class.getName());
         static {
              URL url = null;
              try {
                   //URL baseUrl;
                   //baseUrl = demo.client.JAXWS_Service.class.getResource(".");
                   url = new URL("http://localhost:4444/JAX_WSDemo/JAXWSBean");
              } catch (MalformedURLException e) {
                   logger
                             .warning("Failed to create URL for the wsdl Location: 'file:/E:/zwz/EclipseWorkspace/JAX_WSDemo/WebRoot/META-INF/JAX_WS.wsdl', retrying as a local file");
                   logger.warning(e.getMessage());
              JAXWS_WSDL_LOCATION = url;
         public JAXWS_Service(URL wsdlLocation, QName serviceName) {
              super(wsdlLocation, serviceName);
         public JAXWS_Service() {
              super(JAXWS_WSDL_LOCATION, new QName("http://www.example.org/JAX_WS/","JAXWSBeanService"));  //JAX_WS
         @WebEndpoint(name = "JAX_WSPort")
         public JAXWS getJAXWSSOAP() {
              return super.getPort(new QName("http://www.example.org/JAX_WS/","JAX_WSPort"), JAXWS.class);  //JAX_WSSOAP
    }But i get the exception:
    Exception in thread "main" com.sun.xml.internal.ws.wsdl.parser.InaccessibleWSDLException: 2 counts of InaccessibleWSDLException.
    java.net.SocketException: Unexpected end of file from server
    java.net.SocketException: Unexpected end of file from serverAnd the TCPMon doesn't receive anything.
    If i use Axis2, the TCPMon will work fine.
    I cannot figure out how to configure the webservices.
    Could anyone help me? Thanks a lot.

    [http://blog.vinodsingh.com/2007/02/monitor-soap-messages.html|http://blog.vinodsingh.com/2007/02/monitor-soap-messages.html]
    Edited by: vinod.singh on 7 Apr, 2009 11:03 AM

  • How to make a Struts message null after used in JSP?

    Hi,
    In the context of Struts/JSP,
    An action class might write error messages by
    ActionError msg = new ActionError("msg.request.something");
    ActionErrors msgs = new ActionErrors();
    msgs.add(ActionErrors.GLOBAL_ERROR,msg);
    saveErrors(request,msgs);
    This message will produce a popup modal window by the following JSP code:
    <logic:messagesPresent>
    <html:messages id="error">
    <!--<li class="infomsg"><bean:write name="error"/></li> -->
    <script>javascript:alert('<%=error%>')</script>
    </html:messages>
    </logic:messagesPresent>
    The problem is that this JSP page is shared by serveral actions: when another action invoke this page again, the previous error message will take effect again.
    So my question is how to make message null after used once by its author.
    Thx.
    PY

    msgs = null;

  • Workshop - How to send a SOAP message directly into a JMS qeue......

    Hi All,
    I need to create a web service in Workshop that sends the received SOAP message
    body to a queue without mapping it to Java object i.e. the JMS message type is
    text message and not Object message. I would very much appreciated if anyone out
    there who can advise me on this.
    Thanks in advance.
    Regards,
    Boon Keong

    Hi,
    Are you open for other solutions besides Workshop?
    WebLogic Server provides another Web Service implementation outside of Workshop.
    This web service implentation has a concept of handlers which intercept SOAP
    messages. It is a way to gain access to the SOAP message. You could then route
    the SOAP message to a JMS queue from the handler.
    These URLs will help:
    http://e-docs.bea.com/wls/docs70/webserv/index.html
    http://e-docs.bea.com/wls/docs70/webserv/design.html#1053805
    Also, there is an examples in the WebLogic Server 7.0 installation:
    %BEA_HOME%\samples\server\src\examples\webservices\handler
    hope this helps,
    pat
    "Boon Keong" <[email protected]> wrote:
    >
    Hi All,
    I need to create a web service in Workshop that sends the received SOAP
    message
    body to a queue without mapping it to Java object i.e. the JMS message
    type is
    text message and not Object message. I would very much appreciated if
    anyone out
    there who can advise me on this.
    Thanks in advance.
    Regards,
    Boon Keong

  • How to view the SOAP message in a web service call + Urgent

    Hi All,
    Iam trying to test a web service call(Iam using CXF). But I need to view SOAP message sent to web service or need to debug the web service call. Please help me on this regard with example.

    Yes. to find any tcp monitor, define a listen port number, task host and port number, changing your request to listen post, then you can monitor TCP/IP like
    HTTP/1.1 200 OK
    Set-Cookie: JSESSIONID=7A00BD65EF7516AD8947359A25C4D98B; Path=/ComponentName
    Content-Type: text/xml;charset=utf-8
    Date: Wed, 20 Oct 2004 15:45:03 GMT
    Server: Apache-Coyote/1.1
    Connection: close
    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
    <ns1:testObjectResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:ComponentName">
    <testObjectReturn href="#id0"/>
    </ns1:testObjectResponse>
    <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:MyObject" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="urn:ComponentName">
    <name xsi:type="xsd:string">Set Name</name>
    <value xsi:type="xsd:string">set Value</value>
    </multiRef>
    </soapenv:Body>
    </soapenv:Envelope>
    Lixin

  • How do i get soap message

    Hi everyone.
    I've generated a web service in netbeans 5.5 with SAAJ.
    I've run my web service client. The incoming message (service soap response) is
    empty.
    The problem is, my soap message (payload) is not appearing in the soap response.
    I expect to see....
    <?xml version="1.0" ?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://mywork">
    <soapenv:Body>
    <ns1:getMessageResponse>
    <document>transfer<document>
    <number>123456<number>
    <telephone>555-12345<telephone>
    </ns1:getMessageResponse>
    </soapenv:Body>
    </soapenv:Envelope>
    But i receive the "return" element only, without payload.
    <ns1:getMessageResponse>
    <return/>
    </ns1:getMessageResponse>
    My service and client method is listed below.
    Service....
    public SOAPMessage getMessage() {
    SOAPMessage message = null;
    try {
    MessageFactory mf = MessageFactory.newInstance();
    message = mf.createMessage();
    SOAPPart sp = message.getSOAPPart();
    SOAPEnvelope env = sp.getEnvelope();
    SOAPBody body = env.getBody();
    SOAPHeader header = env.getHeader();
    header.detachNode();
    SOAPFactory sf = SOAPFactory.newInstance();
    Name ElName = sf.createName("getMessage", "ns1", "http:mywork");
    SOAPBodyElement sbe = body.addBodyElement(ElName);
    SOAPElement name = sbe.addChildElement("name");
    name.addTextNode("transfer");
    SOAPElement document = sbe.addChildElement("document");
    document.addTextNode("123456");
    SOAPElement telephone = sbe.addChildElement("telephone");
    telephone.addTextNode("555-12345");
    message.saveChanges();
    } catch (Exception e) {
    System.out.println(e.getMessage());
    return message;
    Client Request....
    public static void main(String[] args) {
    // TODO code application logic here
    try {
    SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
    SOAPConnection con = scf.createConnection();
    MessageFactory mf = MessageFactory.newInstance();
    message = mf.createMessage();
    SOAPPart sp = message.getSOAPPart();
    SOAPEnvelope env = sp.getEnvelope();
    SOAPBody body = env.getBody();
    SOAPHeader header = envelope.getHeader();
    header.detachNode();
    SOAPFactory sf = SOAPFactory.newInstance();
    Name ElName = sf.createName("getMessage", "ns1", "http:mywork");
    SOAPBodyElement sbe = body.addBodyElement(ElName);
    message.saveChanges();
    URL urlep = new URL("http://localhost:8080/jaxws05/jaxws05?WSDL");
    SOAPMessage reply = con.call(message, urlep);
    con.close();
    } catch(Exception ex) {
    // TODO handle custom exceptions here
    Can anyone please help? , Thanks. --Nelson                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    I'd suggest you post this in the workshop newsgroup.
    I don't believe Workshop supports SOAP w/attachments in the current
    release, but you should ask in the workshop group for suggestions.
    -- Rob
    John wrote:
    I'm trying to create a web service which takes an attachment and in
    the BEA site, they have an example called "filetransfer" which does
    what I'm looking for.
    The example uses a SOAPMessageContext.getMessage() and
    SOAPMessage.getAttachments(); however, there doesn't seem to be any
    properties or methods which returns any of these object types.
    Are handling file attachments beyond the scope of weblogic workshop,
    or is there another way around this using workshop?
    Thanks.

  • How to intercept the soap messages.

    hi,
    I have developed a web service using jax-rpc. i know that when a client invokes the web service a SOAP message is sent to the server. Is there any tool that can intercept the SOAP message so that i can edit the message before it is sent to the server. I tried to download this tool called soapmonitor from westbridgetech.com but the site was not working. please help.
    regards,
    kartik.

    Maybe TCPMon would do the trick for you:
    http://ws.apache.org/commons/tcpmon/tcpmontutorial.html

  • How to get full SOAP message sent from XI to web srvice

    Hi guys!
    In my scenario IDoc->XI->SOAP I need to see the SOAP message, which arrives into target web service. Where can I see it? I suppose in sxmb monitor, but which part? I can not find it...
    Thanx, Olian

    In MONi you will only be able to see the XML payload or rather the SOAP Body.
    If you want to see the entire HTTP post message used by the SOAP adapter will the SOAP Enevlope you need to use either,
    1. The TCP Gateway as shown in Stefan's Blog
    or,
    2. Follow the instructions in this thread. You would need to turn on Synch Logging in the Visual Admin for this though,
    Monitoring SOAP Message Payload
    I would suggest you follow Stefan's blog as it is quite simple rather than turning on Synch Logging in the Va.
    Regards
    Bhavesh

  • How to intercept incoming SOAP messages?

    I'm using weblogic workshop 8.1 for creating web services. I need to intercept incoming SOAP messages in order to do some processing before executing the required function (especially i would like to be able to know which function is to be executed and if required, execute an athorer one, according to the processing result)
    I've tryed the tutorial given in the help, but i can't get it work. I'm using the example here after and i'm getting the following error: " the element '@jws:handler' is not allowed at this location".
    package Handler;
    * @jws:handler operation="handler.ConsoleLoggingHandler"
    public class HandlerExample1 implements com.bea.jws.WebService
    static final long serialVersionUID = 1L;
    /** @common:operation */
    public String echoString(String inputString)
    return inputString;
    I will apreciate if some one has a clue to resolve this problem.
    Thank you

    Hello,
    From [1], Handlers on incoming messages are invoked before the message
    is delivered to the web service operation, and handlers on outgoing
    messages are invoked after the web service operation has completed. The
    web service itself is unaware of the presence of handlers. SOAP message
    handlers are sometimes referred to as interceptors. Also see [2][3].
    Did you include the code for the handler
    (handler.ConsoleLoggingHandler)? [4]
    Here's a simple handler example [5]
    Hope this is of some value,
    Bruce
    [1]
    http://e-docs.bea.com/workshop/docs81/doc/en/workshop/guide/getstarted/conSOAPHandlers.html
    [2]
    http://e-docs.bea.com/workshop/docs81/doc/en/workshop/guide/getstarted/conSOAPHandlers.html?skipReload=true#WhereHandlersFit
    [3]
    http://edocs.beasys.com/wls/docs81/webserv/interceptors.html#1060763
    [4]
    http://e-docs.bea.com/workshop/docs81/doc/en/workshop/guide/getstarted/conSOAPHandlers.html?skipReload=true#HandlerExample
    [5]
    http://webservice.bea.com/log.zip
    Fatna wrote:
    >
    I'm using weblogic workshop 8.1 for creating web services. I need to intercept incoming SOAP messages in order to do some processing before executing the required function (especially i would like to be able to know which function is to be executed and if required, execute an athorer one, according to the processing result)
    I've tryed the tutorial given in the help, but i can't get it work. I'm using the example here after and i'm getting the following error: " the element '@jws:handler' is not allowed at this location".
    package Handler;
    * @jws:handler operation="handler.ConsoleLoggingHandler"
    public class HandlerExample1 implements com.bea.jws.WebService
    static final long serialVersionUID = 1L;
    /** @common:operation */
    public String echoString(String inputString)
    return inputString;
    I will apreciate if some one has a clue to resolve this problem.
    Thank you

  • How to make Mutt list messages in a descending order

    Hey.
    How do I make mutt list my messages with the newest message at the top, like in the web interface of Gmail? It is called descending listing starting with the newest message, I suppose.

    .:B:. wrote:
    I have recently switched to Mutt myself, and the manual is unfortunately not a good thing to start. I have pieced together a nice config mainly by googling and stealing stuff from other people's configuration files.
    The setting you want is
    set sort = reverse-date-received
    That will show the most recent mails on top.
    If you want it threaded according to the most recent e-mail in a thread, this should work:
    set sort=threads
    set sort_browser=reverse-date
    set sort_aux=last-date-received
    Alternatively you might use
    sort_aux=reverse-last-date-received
    Hey, thanks. The first one did not work for me, but the second (alternate) did, so this would be the correct config:
    set sort=threads
    set sort_browser=date
    set sort_aux=reverse-last-date-received

  • How to make most recent messages appear at the top of the list?

    I can not find a place in Mail preferences to make my messages in each mailbox ALWAYS appear with the most recent at the top of the list. They seem to revert to the reverse order, even though I laboriously change the order in each mailbox via clicking the top of the date column. I am using primarily .Mac addresses in IMAP format, and three computers. It seems that after I shut down, then restart the next day and my computers all sycn with .Mac, the order goes back to oldest first. How can I fix this? Thanks!

    Everytime i have used webmail, the view is always retained with my previous settings. In fact the .Mac web mail help menu says the same thing (see below)
    Therefore the last thing i would recommend is to simply reset safari (which will empty the cache), delete all your Mail plist files, and not turn .Mac sync on fully until all systems are sorting consistently on their own....
    (from the .mac help menu)
    ===================
    Sorting message lists
    When you use .Mac Mail on the web, you can sort your messages, drafts, and sent messages lists by their column headers. Sorting is helpful when you want to quickly locate specific emails or groups of emails, such as all messages received from a specific sender or all flagged messages.
    To sort a message list:
    If you're not already in .Mac Mail on the web, go to www.mac.com and click Mail (at the top of the page), and log in.
    Access a message list by opening a folder.
    Click any column header to sort the list by that parameter. Clicking the same column header again reverses the order in which the list is sorted.
    When you sort a message list, all email messages in the list are sorted, not just those showing on the current page.
    Column headers vary slightly by list. The Drafts list, for example, has no From column.
    After you have sorted a list, it retains that order until you re-sort it.

Maybe you are looking for

  • HT1918 how do i remove my credit card from itunes account

    how do i remove my credit card from itunes account

  • How can I delete an event that was created somewhere else and sent to me?

    I have been sending myself invites from my work email (Outlook Calendar), and some of them have a recurrance.  I am looking to delete some of the events, but I can't figure out how to do it. Help?

  • Fill Multiline container from multi records in source XML ?

    Hi, scenario: File-XI-RFC-File(BPM). Read company id from source file, call BAPI(company_get_detail) using RFC receiver adapter and then write response to another file. This works fine for one record(one RFC call to BAPI) using the BPM. Now, I would

  • Batch price

    Dear friends The requirement is Scenario: The selling price of the product is based on the MRP that is reverse calculation; we need to handle one issue. When the MRP price of the packet change the selling also changes Here the issue is, when the syst

  • CQ5 developer needed

    We are a leading digital agency in London looking for a CQ5 developer to work on a mobile project for a global brand with an immediate start. Please get in touch if you're interested. Thanks!