I've been able to use this Metadata API built on APEX platform: https://github.com/financialforcedev/apex-mdapi
But it is working if I install this into the org, and user log into the org. WHat I want is to access the API using force.com Site, in which I pass on the session id via URL and session ID is readable from parameters and the metadata listing works for that outside org.
I've modified the MetadataService.cls file and make sure that Session ID is "not" UserInfo.getSessionId(), but is passed into the CreateService Function as input parameter and wherever I call CreateService I pass on the session ID from page parameters.
Earlier I was getting this particular error on the Visualforce Page exposed on Sites:
System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: UNKNOWN_EXCEPTION: Site under construction faultcode=UNKNOWN_EXCEPTION faultactor=
To resolve this, I edited the Service Endpoint to the instance url of the Org whose SessionId I'm passing in this page.
But I'm receiving this error now:
WebService returned a SOAP Fault: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session faultcode=sf:INVALID_SESSION_ID faultactor=
Does anyone know a way to make this Metadata API work on public sites?