locked
Error CreateResponse in Web Service RRS feed

  • Question

  • Good Morning,

    I'm trying develop a Web Service in Visual Studio for CRM. I want create a sales order, but the follow error shows in this line...

     

         TargetCreateSalesOrder target2 = new TargetCreateSalesOrder();

                target2.SalesOrder = encomenda;

     

                //Execute the request.

                CreateRequest createRequest = new CreateRequest();

                createRequest.Target = target2;

     

         CreateResponse createResponse = (CreateResponse)service.Execute(createRequest);----->Server was unable to process request.

     

    Can someone help me? thanks


    Best regards, Maria Cunha.
    Friday, June 10, 2011 10:00 AM

Answers

All replies

  • Why server was unable to process request?? I did the targetcreate sales order.... :s
    Best regards, Maria Cunha.
    Friday, June 10, 2011 1:26 PM
  • Hi,

    You can catch webservice exception to get more details and probably you are missing sales order required fields.

    catch (System.Web.Services.Protocols.SoapException ex)
    {

      string wod_ErrorText = ex.Detail.InnerText
      // You Code

    }

    You can check for the required fields here: http://msdn.microsoft.com/en-us/library/gg309678.aspx


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Friday, June 10, 2011 5:10 PM
  • 500 errors are so non-descriptive.  Anyways.  I think we might need to see more of your code to crack this one. 

    The other option would be to debug in visual studio and track it down further.  If this is a plugin you can do an attachment to the remote server's w3wp.exe (if on a different server you need to install and configure Visual Studio remote debugger) process on our server and step through the code to see where it is failing.  You will also want to register your plugin on-disk and include the pdb file with the dll in the /server/bin/assembly folder.

    If it's not a plugin you should be able to debug it locally.  You can also use fiddler2  - http://fiddler2.com to see the messages that are sent across the wire to see if your request looks funny.


    Jamie Miley
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!
    Friday, June 10, 2011 5:12 PM
    Moderator
  • hi, this is my code

     

    public string Cria_oportunidade( decimal Valor_oport, int probabilidade, string descricao, decimal Valor_estimado)
        {
          try
          {
            //Retrieve the organization name from the query string. 
            string orgname = "ISI-EquipaB2";
    
    
            Microsoft.Crm.SdkTypeProxy.CrmService service = new Microsoft.Crm.SdkTypeProxy.CrmService();
            service.Credentials = new System.Net.NetworkCredential("admin", "pass", "domainl");
            service.Url = "http://localhost:5555" + "/MSCRMServices/2007/CrmService.asmx";
    
            CrmAuthenticationToken token = new CrmAuthenticationToken();
            token.OrganizationName = orgname;
            service.CrmAuthenticationTokenValue = token;
            service.PreAuthenticate = true;
    
    
            //create a account
    
            CrmMoney valor = new CrmMoney();
            valor.Value = Valor_oport;
            CrmMoney valor_estimado = new CrmMoney();
    
            valor_estimado.Value = Valor_estimado;
            CrmNumber prob = new CrmNumber();
            prob.Value = probabilidade;
    
    
    
            CrmBoolean verd = new CrmBoolean();
            verd.Value = true;
    
            DateTime _DateTime = new DateTime(1990, 2, 22);
            CrmDateTime data = new CrmDateTime();
            data.Value = _DateTime.ToString("s");
    
            // Customer maria = new Customer();
            //Guid id_cliente = new Guid();
            
            
            
    
    
            opportunity oport = new opportunity();
            oport.actualvalue = valor;
            oport.closeprobability = prob;
           oport.customerid= maria;
            oport.description = descricao;
            oport.campaignid = null;
            oport.estimatedclosedate = null;
            oport.estimatedvalue = valor_estimado;
            oport.isrevenuesystemcalculated = verd;
            oport.actualclosedate = data;
            oport.createdby = null;
            oport.createdon = null;
    
    
            oport.exchangerate = null;
            oport.importsequencenumber = null;
            oport.modifiedby = null;
            oport.modifiedon = null;
            oport.name = "susana fofinha";
            oport.opportunityratingcode = null;
            oport.originatingleadid = null;
            oport.overriddencreatedon = null;
            oport.ownerid = null;
            oport.owningbusinessunit = new Lookup();
            oport.participatesinworkflow = null;
            oport.pricelevelid = null;
            oport.pricingerrorcode = null;
            oport.prioritycode = null;
            oport.salesstagecode = null;
            oport.statecode = null;
            oport.statuscode = null;
            oport.stepid = null;
            oport.stepname = null;
            oport.timezoneruleversionnumber = null;
            oport.transactioncurrencyid = null;
            oport.utcconversiontimezonecode = null;
    
    
    
    
            // Create the target object for the request.
    
    
            TargetCreateOpportunity target = new TargetCreateOpportunity();
    
            target.Opportunity = oport;
    
    
    
    
            // Create the request object.
            CreateRequest createRequest = new CreateRequest();
            createRequest.Target = target;
    
            // Execute the request.
            CreateResponse createResponse =
              (CreateResponse)service.Execute(createRequest);
    
    
            Guid oportID = createResponse.id;
    
            //Display the GUID. 
            return oport.ToString();
    
    
          }
          catch (SoapException error)
          {
            throw new InvalidPluginExecutionException(error.Detail.SelectSingleNode("//description").InnerText);
          }
        }
    
        public Customer maria { 
          get; set; }
      }

     

    the problem now is customerID. I want introduce manually the code...


    Best regards, Maria Cunha.
    Friday, June 10, 2011 5:26 PM
  • Hi,

    You can add customer id like this:

    Lookup CustomerEntityLookup = new Lookup();

    // you can get the customer record id {7EC1E3A2-6B8C-E011-A88A-E5EF0498D042} by opening then customer record and copy it from browser address bar
    lookup.Value = new Guid("{7EC1E3A2-6B8C-E011-A88A-E5EF0498D042}");
    lookup.type = EntityName.account.ToString();

    oport.customerid= CustomerEntityLookup;


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Friday, June 10, 2011 8:43 PM
  • It gives error on lookup that is not defined and  in the second CustomerEntityLookup  is not of type Customer ...


    Best regards, Maria Cunha.
    Friday, June 10, 2011 9:47 PM
  • Hi,

    Try this:

    Lookup CustomerEntityLookup = new Lookup();

    // you can get the customer record id {7EC1E3A2-6B8C-E011-A88A-E5EF0498D042} by opening the Account record and then copy it from browser address bar
    CustomerEntityLookup .Value = new Guid("{7EC1E3A2-6B8C-E011-A88A-E5EF0498D042}");
    CustomerEntityLookup .type = EntityName.account.ToString();

    oport.customerid= CustomerEntityLookup;


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Friday, June 10, 2011 11:43 PM
  • I've done this, but gives error in oport.customerid = CustomerEntityLookup;

    because oport.customerid is Type Customer...


    Best regards, Maria Cunha.
    Friday, June 10, 2011 11:58 PM
  • Hi, i forget its customer type. Use it like this:

     Customer CustomerEntityLookup = new Customer();
     
    // you can get the customer record id {7EC1E3A2-6B8C-E011-A88A-E5EF0498D042} by opening the Account record and then copy it from browser address bar
    CustomerEntityLookup.Value = new Guid("{7EC1E3A2-6B8C-E011-A88A-E5EF0498D042}");
    CustomerEntityLookup.type = "account";
     
    oport.customerid= CustomerEntityLookup;


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Saturday, June 11, 2011 12:14 AM
  • Thanks... :P
    Best regards, Maria Cunha.
    Saturday, June 11, 2011 12:31 AM
  • Hi,

    I believe it answers your question Please Mark it as Answer.


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Saturday, June 11, 2011 2:31 PM