Reply
Visitor
Cratos
Posts: 2
0

apex ksoap java

Hello. Does anyone know how to acces apex classes through ksoap2 using java (android). This is what i have so far:

 

My login.

SoapObject binding = new SoapObject(NAMESPACE, "login");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(binding);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);

 From a succesful login i get the session id:

sessionId=result.getProperty("sessionId").toString();

 Then i form a header:

headerOut = new Element[1];
Element sessionHeader = new Element().createElement(NAMESPACE,"SessionHeader");
Element sessionIdNode=sessionHeader.createElement(NAMESPACE, "sessionId");
sessionIdNode.addChild(Node.TEXT, sessionId);
sessionHeader.addChild(Node.ELEMENT,sessionIdNode);
headerOut[0]=sessionHeader;

 Now i can access the data by  SOQL queries but i want to acces my apex classes too. (Oh and i got the url to access queries from the login response.)

 

But what i cant do is access my created Apex classes.

 

For example this simple one:

 global class HelloWorld {
     webservice static String hello() {
     return 'Hi';
 }
}

 

I try to acces this by:

SoapObject request2 = new SoapObject(NAMESPACE2, METHOD_NAME2); 
    	SoapSerializationEnvelope envelope2 = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
    	envelope2.headerOut=headerOut;
    	envelope2.setOutputSoapObject(request2);
    	HttpTransportSE androidHttpTransport2 = new HttpTransportSE(URL2);
    	SoapObject result2=null;
    	try 
    	{
    	    androidHttpTransport2.call(SOAP_ACTION2, envelope2)
....

 just like the login but i get the namespace and the url from an apex class wsdl file and form a sessionheader, same method works with queries.

 

Do you guys have some ideas what could be wrong? I tried all the possible url and namespace changes i could think off, and all other things i could have tried. With some settings i get the error SoapFault message=No service available for class 'HelloWorldr.' with others my application just crashes.

 

Hope you understood my problem. If not then sorry, english is not my native language