This discussion is archived
6 Replies Latest reply: Feb 7, 2013 4:17 PM by Nello88 RSS

How to send SOAP Message with Oracle B2B

Nello88 Newbie
Currently Being Moderated
Hi everyone,

I need your help to send out from Oracle B2B a SOAP message with attachment of any type of file (image, pdf, etc.). Possibly using a SOA composite application or another way, it doesn't matter. I already create an ebMS partnership with a custom document protocol and I already create a working SOA composite application to send only text message to my trading partner. I have tried this solution: http://anuj-dwivedi.blogspot.it/2011/04/ebms-attachment-handling-in-oracle-b2b.html but it doesn't work for my case... It is to be noticed that I don't give any schema to my component in the SOA application explained firstly, and I select opaque as schema.

Thanks to all, regards

Nello
  • 1. Re: How to send SOAP Message with Oracle B2B
    Anuj Dwivedi Guru
    Currently Being Moderated
    Hi Nello,

    Can you provide more details about the error? What is not working? Do you get any error in B2B?

    Regards,
    Anuj
  • 2. Re: How to send SOAP Message with Oracle B2B
    Nello88 Newbie
    Currently Being Moderated
    Hi Anuj and thanks for your help,

    I need to send an ebXML message, with SOAP, and I try to send it with a .war application written in jsp connecting to http://10.85.28.24:8001/b2b/transportServlet to send the SOAP message. The errors reported is:
    javax.xml.soap.SOAPException: Unable to receive message. Received a response from url: http://10.85.28.24:8001/b2b/transportServlet with HTTP status 200 and SOAP content-type: null.

    the code I write is the following (to evaluate the two "null" in the super constructor)

    <%!
    public class EBMSSender extends SOAPRunner
    {
    private String cpaId;
    private String service;
    private String action;
    private String mess;


    private ArrayList<String> allegati=null;

    public EBMSSender(String cpaId, String service, String action, String mess, ArrayList<String> file)
    {
    super("http://10.85.28.24:8001/b2b/transportServlet","null", "null");
    this.cpaId = cpaId;
    this.service = service;
    this.action = action;
    this.mess=mess;
    this.allegati=file;

    }



    @Override
    protected void prepareRequest(SOAPMessage soapMessage, SOAPBody soapBody) throws SOAPException
    {
    soapBody.addChildElement(SOAPUtility.createElement("CPAId", getNsPrefix(), getNsURI(),"agr3"));
    soapBody.addChildElement(SOAPUtility.createElement("service", getNsPrefix(), getNsURI(),"OracleService"));
    soapBody.addChildElement(SOAPUtility.createElement("action", getNsPrefix(), getNsURI(),"Oracletohermesb"));
    soapBody.addChildElement(SOAPUtility.createElement("serviceType", getNsPrefix(), getNsURI(),"OracleServiceType"));



    soapBody.addChildElement(SOAPUtility.createElement("convId", getNsPrefix(), getNsURI(), "convId"));
    soapBody.addChildElement(SOAPUtility.createElement("fromPartyId", getNsPrefix(), getNsURI(), "Oracle"));
    soapBody.addChildElement(SOAPUtility.createElement("fromPartyType", getNsPrefix(), getNsURI(), "Name"));

    soapBody.addChildElement(SOAPUtility.createElement("toPartyId", getNsPrefix(), getNsURI(), "Hermes-b"));
    soapBody.addChildElement(SOAPUtility.createElement("toPartyType", getNsPrefix(), getNsURI(), "Name"));



    attach(soapMessage);
    }

    protected void attach(SOAPMessage soapMessage)
    {
    String h=mess;

    DataHandler dh;



    AttachmentPart ap = soapMessage.createAttachmentPart(h,"text/plain");

    soapMessage.addAttachmentPart(ap);

    if(allegati!=null)
    {
    for(int i=0; i<allegati.size();i++)
    {
    dh=new DataHandler(new FileDataSource(new File(allegati.get(i))));
    ap=soapMessage.createAttachmentPart(dh);
    ap.setContentType(new MimetypesFileTypeMap().getContentType(allegati.get(i)));
    ap.setContentLocation(allegati.get(i));
    soapMessage.addAttachmentPart(ap);


    }

    }



    }

    @Override
    protected void processFault(SOAPFault soapFault) throws SOAPException{}

    @Override
    protected Object processResponse(SOAPMessage responseMessage,SOAPBody responseBody) throws SOAPException
    {
    SOAPElement messageId = SOAPUtility.getChild(responseBody, "message_id", getNsURI());
    return null;
    }
    }

    %>


    The code works fine on the other trading partner side to send ebXML message to Oracle B2B. Apart from this solution (however,it would be my favorite), I find your blog and I try to implement your solution. It works: it sends files with only text payload to the other trading partner without any problem, but if I try to send for example an image in byte array written in a file .txt, the ebxml file received has the byte array with wrong characters. it may be that I have not provided the xsd schema? in case if I wanted to send an ebXML message with text and attachments, what xsd schema do I need to provide?
    or is there another way to implement a SOA composite application to send SOAP messages with attachments?

    Thank for your help!, regards

    Nello
  • 3. Re: How to send SOAP Message with Oracle B2B
    Anuj Dwivedi Guru
    Currently Being Moderated
    Hi Nello,

    I am afraid that you are confusing between inbound and outbound.

    My blog post discusses about how to SEND the message with attachment over ebMS to a remote trading partner (outbound) whereas B2B transport servlet (http://host:port/b2b/transportServlet) is used to receive the messages from trading partners (inbound)

    Can you please explain what is your use case? Receiving message from TP (inbound) or sending message to TP (outbound)?
    but if I try to send for example an image in byte array written in a file .txt, the ebxml file received has the byte array with wrong characters.
    To transfer binary attachments, it is recommended to use JMS as AQ expects base64 encoded attachment XML and if you are including binary attachment as content in attachment XML then it may get corrupted during base64 encoding and decoding. If I am not wrong then PS3 (11.1.1.4) has a known bug related to this. In my blog, I included binary attachment as reference in the attachment XML. To know that how to post attachment over JMS, you may refer -

    http://anuj-dwivedi.blogspot.in/2011/04/rosettanet-attachment-handling-in.html

    Please use ebMS attachment XSD for ebMS (not the RosettaNet one described in above link)

    Regards,
    Anuj
  • 4. Re: How to send SOAP Message with Oracle B2B
    Nello88 Newbie
    Currently Being Moderated
    ok, I want to send a ebMS message to trading partner (outbound), so now I retry your solution with the new indications you have gave to me. however is there a Http service in Oracle B2B to connect to send a "classical SOAP message"? and where does ebMS XSD need to be loaded? in the configuration of FileAdapter and in the configuration of B2B adapter?

    thanks for your help, regards.

    Nello.
  • 5. Re: How to send SOAP Message with Oracle B2B
    Anuj Dwivedi Guru
    Currently Being Moderated
    however is there a Http service in Oracle B2B to connect to send a "classical SOAP message"?
    Generic SOAP is not supported as of now. AFAIK, the next patch set (11.1.1.7.0) will have a support for it.
    and where does ebMS XSD need to be loaded
    Do you mean ebMS attachment XSD? If yes then you may need to load it in file adapter to read the attachment XML. You may also hard-code attachment XML in a variable (for testing purpose) in BPEL, instead of reading it from a file location.

    Regards,
    Anuj
  • 6. Re: How to send SOAP Message with Oracle B2B
    Nello88 Newbie
    Currently Being Moderated
    Thanks Anuj,

    I have solved using your solution on your blog with the hints that you have gave to me on this forum. I used in the wrong way the ebMS attachement XSD schema, however to avoid a possible bug, I put a file already converted to base64 in the folder pointed by the file adapter.

    You have been kind and helpful, thank you very much.

    regards,

    Nello

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points