3

I'm searching a simple Webservice test on Salesforce. I created a simple WS

global class AccountPlan {

   webservice String area; 
   webservice String region; 

   //Define an object in apex that is exposed in apex web service
   global class Plan {
      webservice String name;
      webservice Integer planNumber;
      webservice Date planningPeriod;
      webservice string planId;
   }

   webservice static Plan createAccountPlan(Plan vPlan) {

   //A plan maps to the Account object in salesforce.com. 
   //So need to map the Plan class object to Account standard object
   Account acct = new Account();
   acct.Name = vPlan.name;
   acct.AccountNumber = String.valueOf(vPlan.planNumber);
   insert acct;
   vPlan.planId=acct.Id;
   return vPlan;
  }
}

And i'm searching to call it using SoapUI (4.6.0) making a Simple soap call.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:acc="http://soap.sforce.com/schemas/class/AccountPlan">
   <soapenv:Header>
      <acc:AllowFieldTruncationHeader>
      </acc:AllowFieldTruncationHeader>
      <acc:SessionHeader>
         <acc:sessionId>00D20000000leM4!AQUAQAbbtdrNRt4vK7SaJ8e2VPefMhAFfTtgDpvKI_8JZlyHJhKOBfCmU6tDiaf4FQau2A1Ni9n9OJbuzR8j1n.zt7n7zcHb</acc:sessionId>
      </acc:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <acc:createAccountPlan>
         <acc:vPlan>
            <acc:name>Klodjan Test</acc:name>
            <acc:planNumber>2</acc:planNumber>
         </acc:vPlan>
      </acc:createAccountPlan>
   </soapenv:Body>
</soapenv:Envelope>

and I'm receiving the follow feedback

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>soapenv:Client</faultcode>
         <faultstring>No service available for class 'AccountPlan'</faultstring>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>

Any one can help me to understand why i'm geting such error... I'm running as system adinistrator...

5
  • what URL are you sending the request to?
    – superfell
    Commented Jul 5, 2014 at 17:36
  • Sorry what you mean whith what URL? I imported the WSDL of the WS in Soap UI and tried to send the soap message above. I suppose that the message is send to "soap.sforce.com/schemas/class/AccountPlan"
    – Klodj_Meta
    Commented Jul 5, 2014 at 18:10
  • its HTTP, so the request goes to a URL. You should be able to see it in Soap UI somewhere. Also did you give the user access to the apex class in their profile?
    – superfell
    Commented Jul 5, 2014 at 22:31
  • Yes the class is visible to the use profile, and also the profile has the api enabled... I'm actually using as request the XML above, i send it using soap UI. I have anything to change... That is the XML generated importing the WSDL I tried to call the WS also from another Salesforce sandbox, but I recieve the same error as using Soap Ui
    – Klodj_Meta
    Commented Jul 5, 2014 at 23:05
  • 1
    Actually I made the WS public adding the class to sites, and it works properly... so I'm understanding less than before...
    – Klodj_Meta
    Commented Jul 6, 2014 at 0:48

2 Answers 2

2
+50

Your code works fine for me. This is the response I got:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns="http://soap.sforce.com/schemas/class/AccountPlan"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soapenv:Body>
      <createAccountPlanResponse>
      <result>
        <name>Klodjan Test</name>
        <planId>001F000001ABD9RIAX</planId>
        <planningPeriod xsi:nil="true"/>
        <planNumber>2</planNumber>
     </result>
  </createAccountPlanResponse>
  </soapenv:Body>
  </soapenv:Envelope>

I would ask, do you have a namespace defined in your org? If so, you would need to modify your endpoint to include the namespace as well. The only other thought would be if you have a proxy in place to access the internet, you need to have the proxy configured correctly in SOAPUI as well.

3
  • My money is on namespace.
    – metadaddy
    Commented Jul 10, 2014 at 2:16
  • Hi, boh I do not understand what happened. I had installed on sandbox just the MobilePack_jQuery package. I removed it, and now works fine. After that I installed again the package to understand if was that the problem, but now works also with the package installed! so I dont understand... mystery... @JimRae I'mgiving you the bounty because looks in someway to do with what you wrote... but for me is not still clear what happened. have any sense for you ? best regards, Klodjan
    – Klodj_Meta
    Commented Jul 11, 2014 at 23:59
  • Thank you. Again, my thought is that the package you had installed somehow impacted your code. Likely, related to the inclusion of a namespace.
    – JimRae
    Commented Jul 12, 2014 at 1:38
1

you can check this answer which has documentation reference on how to accomplish something similar but using REST, it involves slightly more coding but it's more beautiful:) (users authenticate via the oauth2 flow, which will have to be built)

Salesforce to Salesforce API - call apex methods

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .