How to Get SOAPElement BOM in SOAPMessage for Sales Opportunities

Hi experts,
I'm newbie in using Java.
I want to Update Sales Opportunities using SOAPMessage in Java.
So far, this is my sample code:
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
import testws.salesopportunities.BOM;
import testws.util.MyHandler;
public void updateOppr() {
        Service service = Service.create(new QName("UpdateOpportunities"));
        QName portQName = new QName("UpdateOpportunities");
        QName elementbom = new QName("BOM");
        try {
            String endPoint = "http://192.168.56.102/B1WS/service.asmx";
            service.addPort(portQName, javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING, endPoint);
            service.setHandlerResolver(new MyHandler());
            Dispatch<SOAPMessage> sourceDispatch = service.createDispatch(portQName, SOAPMessage.class, Service.Mode.MESSAGE);
            salesOpBOM = (new testws.salesopportunities.ObjectFactory()).createBOM();
            JAXBContext context = JAXBContext.newInstance(salesOpBOM.getClass().getPackage().getName());
            Marshaller marshaller = context.createMarshaller();
            SOAPMessage msg = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL).createMessage();
            // create header
            SOAPHeader header = msg.getSOAPHeader();
            SOAPElement elMsgHeader = header.addChildElement("MsgHeader", "", "http://www.sap.com/SBO/DIS");
            SOAPElement elSession = elMsgHeader.addChildElement("SessionID");          
            elSession.addTextNode(sessionID);
            // create body
            SOAPBody body = msg.getSOAPBody();
            SOAPElement elCommand = body.addChildElement("UpdateObject", "", "http://www.sap.com/SBO/DIS");
            SOAPElement elBOM = elCommand.addChildElement("BOM");           
            SOAPElement elBO = elBOM.addChildElement("BO");
            SOAPElement elAdmInfo = elBO.addChildElement("AdmInfo");
            SOAPElement elObj = elAdmInfo.addChildElement("Object");
            elObj.addTextNode("oSalesOpportunities");
            SOAPElement elQueryParam = elBO.addChildElement("QueryParams");
            SOAPElement elParam1 = elQueryParam.addChildElement("SequentialNo");
            elParam1.addTextNode("69");
            SOAPElement elslsOpLine1 = elBO.addChildElement("SalesOpportunitiesLines");
            SOAPElement elLineRow = elslsOpLine1.addChildElement("Row");
            elLineRow = elslsOpLine1.addChildElement("Row");
            elLineRow = elslsOpLine1.addChildElement("Row");
            SOAPElement elLineRowMaxTotal = elLineRow.addChildElement("MaxLocalTotal");
            SOAPElement elLineRowStageKey = elLineRow.addChildElement("StageKey");
            SOAPElement elLineRowStagePercent = elLineRow.addChildElement("PercentageRate");
            elLineRowStagePercent.addTextNode("85.00");
            elLineRowStageKey.addTextNode("5");
            elLineRowMaxTotal.addTextNode("1000000.00");
            marshaller.marshal(salesOpBOM, elCommand);
            msg.saveChanges();
            SOAPMessage response = sourceDispatch.invoke(msg);
            //End UpdateObject (Update Document / Add Document Lines)
        } catch (Exception ex) {
            ex.printStackTrace();
Edited by: Siddharta on Mar 4, 2011 10:31 AM

After I Debug this code, i get an error message (SOAP Request were trimmed):
Update sales opportunities
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
     <env:Header>
          <MsgHeader xmlns="http://www.sap.com/SBO/DIS">
               <SessionID>D8419D24-4E71-4D10-A425-1ADCCD6020C3</SessionID>
          </MsgHeader>
     </env:Header>
     <env:Body>
          <UpdateObject xmlns="http://www.sap.com/SBO/DIS">
               <BOM>
                    <BO>
                         <AdmInfo>
                              <Object>oSalesOpportunities</Object>
                         </AdmInfo>
                         <QueryParams>
                              <SequentialNo>69</SequentialNo>
                         </QueryParams>
                         <SalesOpportunitiesLines>
                              <Row/>
                              <Row/>
                              <Row>
                                   <MaxLocalTotal>1000000.00</MaxLocalTotal>
                                   <StageKey>5</StageKey>
                                   <PercentageRate>85.00</PercentageRate>
                              </Row>
                         </SalesOpportunitiesLines>
                    </BO>
               </BOM>
               <BOM xmlns="" xmlns:ns3="http://www.sap.com/SBO/DIS"/>
          </UpdateObject>
     </env:Body>
</env:Envelope>
javax.xml.ws.soap.SOAPFaultException: Invalid XML Stream
        at com.sun.xml.internal.ws.fault.SOAP12Fault.getProtocolException(SOAP12Fault.java:210)
        at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:111)
        at com.sun.xml.internal.ws.client.dispatch.DispatchImpl.doInvoke(DispatchImpl.java:176)
        at com.sun.xml.internal.ws.client.dispatch.DispatchImpl.invoke(DispatchImpl.java:195)
        at testws.Main.updateOppr(Main.java:173)
        at testws.Main.main(Main.java:43)
Why there is 2 SOAPElement for <BOM> ?
If my code is wrong, please can you help me?
Is there a way to get SOAPElement <BOM> in SOAPBody so i can update Sales Opportunities Document without addChildElement for <BOM>?
Thanks a lot.
Edited by: Siddharta on Mar 4, 2011 10:38 AM

Similar Messages

  • How to get the back order quantity for sales Order

    Hi Friends,
    I want to get the back order quantity for sales order . in MD04 t-code,
    there is a field(MDEZ-MNG01) for Received Qty/ Required qty.  But MDEZ is a structure.
    I tried from MDTB table, but the table is not updated with the values in MD04.
    Please guide me from which table I can get the back order Qty for sales Order
    (ref: t-code  MD04, MRP element = CusOrd).
    Thanks,
    Sagar

    >
    VIdya Sagar wrote:
    > Hi,
    >
    > Isn't  there any difference b/n Open Sales Order and Back order??
    Yes Quite Difference.
    Read:
    http://www.sap-img.com/sap-sd/explain-the-meaning-of-an-open-sales-order.htm
    http://help.sap.com/saphelp_sbo2005asp1/helpdata/en/b6/bdb9b2f02842348c9edbe78af863c4/content.htm

  • How to get costing BOM from R/3

    Hi friends,
    How to get costing BOM from r/3 with levels into bw.and the transaction in r/3 is ck13n

    Hi,
    You'll need to go in for a generic DS in this case.
    Cheers,
    Kedar

  • How to get the "last changed by" for a set of function modules?

    How to get the "last changed by" for a set of function modules?
    is there any table to get it??

    See [this|Re: Date of creation of function module] I posted earlier.
    >TFDIR will give you the name of the function group program and the include number.
    >E.g. SAPLZFUNCGROUP Include 01.
    >From this you can construct the include name: LZFUNCGROUPU01.
    >You can look this up in TRDIR to find the creation date (CDAT) of the function module.
    In your case, you need unam and udat.
    matt

  • How to get the current month value for a customer exit variable?

    How to get the current month value for a customer exit variable? 
    And also if we have an InfoObject with date value (including date, month, year), then how to derive the month value from this date type of Char.?
    Thanks!

    Hi Kevin,
    Check here........
    Re: Customer Exist for "From Current Date To Month End"
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/25d98cf6-0d01-0010-0e9b-edcd4597335a
    Cal month
    Regards,
    Vijay.

  • How to get the Windows Vista Driver for ATI Radeon 7500 card?

    How to get the Windows Vista Driver for ATI Radeon 7500 card?
    I am using a IBM Thinkpad T42 with a 32Mb ATI Radeon 7500 graphic card AGP.
    Is there any Vista 32-bit driver to update my card so that this system support Aero effect?
    Thank you.
    regards,
    W. Thong

    wthong wrote:
    How to get the Windows Vista Driver for ATI Radeon 7500 card?
    The Radeon 9000 driver works for the Radeon 7500 card.  I have successfully used it on a T43 with Vista Ultimate x86
    wthong wrote:
    Is there any Vista 32-bit driver to update my card so that this system support Aero effect?
    Unfortunately no.  The Radeon 9000 driver should bring your graphics score up to close to 2, but it will not get it high enough to enable Aero support.
    Cheers,
    Bill
    I don't work for Lenovo

  • How to get calender in f4 help for select options in module pool (URGENT)

    Hi All,
    how to get calender in f4 help for select options in module pool
    Please help .
    Thanx in advance,
    amruta

    Hi Amruta,
    First of all, you can not create select-options directly in module pool.
    For creating <b>select-option is dialog prog</b> follow these steps:
    1. create your selection screen model as subscreen by:
    SELECTION-SCREEN BEGIN OF SCREEN 2000 AS SUBSCREEN.
    PARAMETRS: P_MATNR LIKE MARA-MATNR.
    SELECT-OPTIONS: S_BISMAT FOR MARA-BISMAT.
    SELECTION-SCREEN END OF SCREEN 2000.
    2. create a screen ( example 100 ) in your module-pool dedicated for selection-screen. on this screen layout sketch a sub-screen name like subscree_2000.
    3. write this bit of code in PBO and PAI of the screen 100;
    CALL SUBSCREEN SUBSCREEN_2000.
    4. include this code in PBO:
    INCLUDING SY-REPID '2000'
    6. write user_command of PAI, call screen which is going to executable after selection-screen.
    5. create a transcation for this dialog module pool with screen 100.
    6. execute this transaction and you can see it's behaving like cool with select-options.
    After that in [bprocee on value-request]</b>, use F4_DATE for both from and to option field.
    Hope it will solve the problem.
    Regards
    Krishnendu

  • How to get the restriction pass code for iPhone ?

    How to get the restriction pass code for iPhone ?

    if you forgot it you have to restore your phone to get past that code

  • How to  get and download adobe illustrtor for iMac os x 10.7

    how to  get and download adobe illustrtor for iMac os x 10.7    

    www.adobe.com would be a good place to start. You can also visit Apple's Online Store to see if you can order from there. Google search for other vendors.

  • Have an ipod and then got the wife an iphone4. all passwords are screwed up. she can not access playstore cuz she doesn't have password. i can not get find any help on how to get or update a password for the ipod. and then get her a separate password for

    have an ipod and then got the wife an iphone4. all passwords are screwed up. she can not access playstore cuz she doesn't have password. i can not get find any help on how to get or update a password for the ipod. and then get her a separate password for her iphone. we need to save her photos, music, etc to ? icloud and the phone stuff to verizon cloud? so when she gets her new Iphone6 she can have all her "stuff" back on the new phone. hope this makes sense. please offer suggestions here or at [email protected] thanks for your help!

    Oh no! I'm sorry to see there's a lot of confusion here and data shared, x-rayDon. We can definitely work to fix. This happens when two devices share the same Apple ID, so she will need to reset hers. She can do so by assessing this link Apple - My Apple ID. You will need to decide who will keep the account if want separate Apple IDs since purchases cannot be shared unless you do Family Sharing.
    RobinD_VZW
    Follow us on twitter @VZWSupport

  • How to get WHAT U HEAR option for PCI Express X-Fi Titanium sound card and Windows 7

    how to get WHAT U HEAR option for PCI Express X-Fi Titanium sound card and Windows 7 ? Is it on the basic driver? or do you have to install some other software?
    jane

    You have to install the rest of the software(s) for the sound card. The software is (if it is with the installation CD, though) called "Creative Smart Recorder" or something like that.

  • How to get internet on the go for iPad 2, is it possible? Thanks for ur help in advance...

    How to get internet on the go for iPad 2, is it possible? Thanks for ur help in advance...

    If you don't have cellular on your iPad, then you will need a public Wi-Fi access.

  • Does anyone know how to get Adobe to stop charging for a subscription that is no longer being used?

    Does anyone know how to get Adobe to stop charging for a subscription that is no longer being used?

    For full details on cancelling a membership and subscription see the following page:
    Cancel your membership or subscription | Creative Cloud
    Depending on where you are in your subscription cycle / membership and the type of membership
    If you have an individual membership, and opted for the annual membership (lower monthly fee). If you are cancelling in the middle of your membership, then you would be billed 50% of what's left of your membership for the remainder of the year, basically that would then in $$s become more like having taken out a month-by-month membership (higher monthly membership fee).
    If you are in the last month of your annual membership or your are on a month-by-month membership, you can log into your creative cloud account, cancel the plan yourself (no additional charges apply), by logging in with your Adobe ID and password, click your name in top left of screen and click on Manage Account.

  • How 2 get units like paise, cents for different currencies

    hi
    how 2 get units like paise, cents for different currencies
    eg...
    if i give EURO
    i should get CENTS
    Regards,
    Naveen
    Message was edited by:
            Naveen Natarajan

    Hi Naveen Plz used This Function Module and let me known whether this is ur requirment or not : Plz look this function module ..........................
    CALL FUNCTION 'SPELL_AMOUNT'
        EXPORTING
          amount    = amount
          currency  = currency
          language  = sy-langu
        IMPORTING
          in_words  = amt_in_words
        EXCEPTIONS
          not_found = 1
          too_large = 2
          OTHERS    = 3.
      IF sy-subrc <> 0.
        MESSAGE ' AMOUNT NOT CONVERTED TO WORDS : ' TYPE 'E' .
      ENDIF.

  • So where can I get an iPhone 4/4S for sale to use without the contract? Anyone?

    So where can I get an iPhone 4/4S for sale to use without the contract? Anyone?

    Thank you for letting me know!  That is a GREAT deal!  I would buy that if I hadn't already spent my $335 I did earlier at the end of November.  I found a good deal for a new white iTouch 4 64GB which is an iPhone 4 without the contract only it was in the color I wanted and the biggest capacity of the new line of iPhones. But thank you anyways! Like i said if I hadn't already bought mine I would probably do that one.

Maybe you are looking for

  • Help needed on combo-box dynamic values??

    Hi , i need to populate values in 2 combo-boxes where the values in the second combo is dependent on the first .. from db ... i.e if i select a value in 1 combo then the values in the second combo should be populated accordingly from the db.. pls sug

  • Jbuilder compiler problem with xml DOM - please help.

    my problem is that I am using jbuilder 4 professional to compile/run my code. However I want to use the XML DOM but jbuilder does not appear to support the necessary packages for use with XML. How can I get round this. Can I compile instead from the

  • ITunes keeps on crashng on my iPad1

    After 6 months of owning my iPad iTunes and the App store constantly crashes on me. Any help would be appreciated

  • Air print druck geht nicht an iphone1 obwohl iphone2 funktioniert

    Hallo, mein Mann und ich haben beide ein iphone. Ich ein 4er und er ein 4S. Wir nutzen Zuhause den gleichen wlan Zugang und möchten beide über unseren Airprint Drucker drucken. Bei mir funktioniert es, bei meinem Mann nicht. Die Hilfe von Apple biete

  • Color off for User Profile

    Somehow the colors are messed up on a particular user account on my MBP. They seem very saturated. I don't think it has to do with the colorsync utility since if I create a test user account the display looks normal. If I go into the Display properti