function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dumplingdudedumplingdude 

Apex WebService

Please help, I am new to salesforce but I have done some work with webservices before. I am running into a problem accessing an Apex webservice.

 

Apex Class

 

 

Global  class TestSOA {
  Webservice static void testService(){
    List<account> newAccts = new List<account>();
    Account oneAccount = new Account();
    oneAccount.Name = 'Test 1';
    newAccts.add(oneAccount);
    oneAccount.Name = 'Test 2';
    newAccts.add(oneAccount);
  }
}

 

My Code

 

            TestSOAServiceLocator service = new TestSOAServiceLocator();

            TestSOABindingStub sb = new TestSOABindingStub(service);
            SessionHeader sh = new SessionHeader();
            sh.setSessionId(lr.getSessionId());
            
            sb.setHeader(new TestSOAServiceLocator().getServiceName().getNamespaceURI(),"SessionHeader", sh);
            
            sb._setProperty(TestSOABindingStub.ENDPOINT_ADDRESS_PROPERTY, lr
                    .getServerUrl());
            sb.testService();

 

I read the documentation but I didn't find anything about authenticating for an Apex Webservice, my method seems to work but i am getting this error now:

 

"No operation available for request {http://soap.sforce.com/schemas/class/TestSOA}testService"

 

Thanks in advance.

 

 

 

 

SuperfellSuperfell

Don't change the endpoint URL property.

dumplingdudedumplingdude

Thanks. It works.

Alan TangAlan Tang

I had some issue, but after removed this line for endpoint, it doesnot work, i met error "No endpoint".

 

please help~