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
Arup SarkarArup Sarkar 

calling Apex WS from java client

Hi I have the following web service in Apex.

 

global class AccountWebService
{
    webService static Id makeAccount(String AccountName)
    {
        Account acct = new Account();
        acct.Name = AccountName;
        insert acct;
        return acct.Id;
    }

}

 I have created the following java client in java.

 

package com.nb.sfdc.ws.client;

import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;

import org.apache.axis.AxisFault;

import com.sforce.soap.schemas._class.AccountWebService.AccountWebServiceBindingStub;
import com.sforce.soap.schemas._class.AccountWebService.AccountWebServiceServiceLocator;

public class TestWSClient {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		System.setProperty("http.proxyHost", "xxxxx");
		System.setProperty("http.proxyPort", "80");
		
		AccountWebServiceServiceLocator loc = new AccountWebServiceServiceLocator();
		try {
			URL url = new URL(loc.getAccountWebServiceAddress());
			AccountWebServiceBindingStub stub = new AccountWebServiceBindingStub(url,loc);
			stub.setUsername("xxxx");
			stub.setPassword("xxxx");
			stub.makeAccount("testing");
			
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			System.out.println("MalformedURLException: " + e.toString());
		} catch (AxisFault e) {
			// TODO Auto-generated catch block
			System.out.println("AxisFault: " + e.toString());
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			System.out.println("RemoteException: " + e.toString());
		}

	}

}

 I am getting the following error.

 

AxisFault: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session

 

Can someone please help me.