Stan James, The cast and assignment will work fine with any subtype of StubImpl returned by the getCodesServicePort() method.
I understand this and it works fine.. The getCodesServicePort() method returns an object of CodesServicePortType_Stub and when I change the code as
binding = (StubImpl) theMethods[i].invoke(service, null);
the binding object is of CodesServicePortType_Stub and not the StubImpl and am able to call a method which is available in CodesServicePortType_Stub.
And am still learning how JAVA does OOP. thanks for pointing it..