• mbiffi
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies

Hi all,
I'm trying to do an update using xmlbeans-axis2 generated API from partner wsdl,and I can't figure out how to add a custom field to the Opportunity to be updated

Here's the code:

  UpdateDocument updateDocument = UpdateDocument.Factory.newInstance();
  Update update = Update.Factory.newInstance();
  SObject updateOpportunity = SObject.Factory.newInstance();
  updateOpportunity.setType(TYPE);
  updateOpportunity.setId(this.getOpportunityId());
  
  update.setSObjectsArray(new SObject[] { updateOpportunity });
  updateDocument.setUpdate(update);
               
     SaveResult[] saveResults = binding.update(updateDocument,
  this.sessionHeaderDocument, null, null, null, null)
  .getUpdateResponse().getResultArray();

what I would like to do is to add a fieldname+fieldValue to the updateOpportunity object but I can't find how.
Adding an xml node,but how?

Thank you and regards
Massimiliano

  • November 09, 2007
  • Like
  • 0

Hi all,
I'm trying to do an update using xmlbeans-axis2 generated API from partner wsdl,and I can't figure out how to add a custom field to the Opportunity to be updated

Here's the code:

  UpdateDocument updateDocument = UpdateDocument.Factory.newInstance();
  Update update = Update.Factory.newInstance();
  SObject updateOpportunity = SObject.Factory.newInstance();
  updateOpportunity.setType(TYPE);
  updateOpportunity.setId(this.getOpportunityId());
  
  update.setSObjectsArray(new SObject[] { updateOpportunity });
  updateDocument.setUpdate(update);
               
     SaveResult[] saveResults = binding.update(updateDocument,
  this.sessionHeaderDocument, null, null, null, null)
  .getUpdateResponse().getResultArray();

what I would like to do is to add a fieldname+fieldValue to the updateOpportunity object but I can't find how.
Adding an xml node,but how?

Thank you and regards
Massimiliano

  • November 09, 2007
  • Like
  • 0
Hello, I am using axis 2 and having a problem executing queries from my Java code. I have generated the SforceServiceStub.java from the wsdl file, and I am able to connect to the salesforce service successfully (i.e. I can get the server URL, and a session ID). Moreover, the describeGlobal()
function runs great, and returns all the object types. However, when trying to execute a basic
query, I'm getting this error:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
java.lang.RuntimeException: Unsupported type urn:sobject.enterprise.soap.sforce.com Contact
at com.sforce.soap.enterprise.SforceServiceStub$ExtensionMapper.getTypeObject(SforceServiceStub.java:25165)
at com.sforce.soap.enterprise.SforceServiceStub$SObject$Factory.parse(SforceServiceStub.java:16678)
at com.sforce.soap.enterprise.SforceServiceStub$QueryResult$Factory.parse(SforceServiceStub.java:21263) at  com.sforce.soap.enterprise.SforceServiceStub$QueryResponse$Factory.parse(SforceServiceStub.java:40935)
at com.sforce.soap.enterprise.SforceServiceStub.fromOM(SforceServiceStub.java:25016)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

my code is as follows:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public class SampleLogin {    
   
    public static void main(String args[])  {      
     
            SforceServiceStub stub = new SforceServiceStub();
            Options options = stub._getServiceClient().getOptions();
            options.setProperty(HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE);
            options.setProperty(HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE);

            Login lg = new Login();
            lg.setPassword("********");
            lg.setUsername("*******");
            LoginScopeHeader lsh = null;         
            LoginResponse response = stub.login(lg, lsh);
            LoginResult lr  = response.getResult();
                    
            SessionHeader sh = new SessionHeader();
            sh.setSessionId(lr.getSessionId());          
            stub = new SforceServiceStub(lr.getServerUrl());
            options = stub._getServiceClient().getOptions();
            options.setProperty(HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE);
            options.setProperty(HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE);
          
           QueryOptions qOptions = new QueryOptions();
            qOptions.setBatchSize(200);          
            Query q = new Query();
            q.setQueryString("select AccountId from Contact");
            QueryResponse qResponse = stub.query(q, sh, qOptions, null);          
            QueryResult qr = qResponse.getResult();
 }
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Can anyone please suggest what  I may be doing wrong, and point in the right direction ?

Thanks a bunch ahead,
:0)
--Fluffy 

  • October 27, 2007
  • Like
  • 0