You need to sign in to do that
Don't have an account?
jackd
Noob question: No "login" method for metadata api?
Using apache soap to generate soap clients for the "enterprise" and "metadata" wsdls.
The following works great with the "Enterprise" wsdl::
binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
loginResult = binding.login(userName, password);
binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY,
loginResult.getServerUrl());
SessionHeader sh = new SessionHeader();
sh.setSessionId(loginResult.getSessionId());
binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(),
"SessionHeader", sh);
//all subsequent calls work great
However, I must be missing something in the metadata api. There is no "login" method on the MetadataBindingStub generated from the metadata.wsdl ... how does one login and create a session?
metaBinding = (MetadataBindingStub) new MetadataServiceLocator().getMetadata();
metaBinding.setUsername(userName);
metaBinding.setPassword(password);
metaBinding.describeMetadata(); // >> INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
Thanks.
The following works great with the "Enterprise" wsdl::
binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
loginResult = binding.login(userName, password);
binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY,
loginResult.getServerUrl());
SessionHeader sh = new SessionHeader();
sh.setSessionId(loginResult.getSessionId());
binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(),
"SessionHeader", sh);
//all subsequent calls work great
However, I must be missing something in the metadata api. There is no "login" method on the MetadataBindingStub generated from the metadata.wsdl ... how does one login and create a session?
metaBinding = (MetadataBindingStub) new MetadataServiceLocator().getMetadata();
metaBinding.setUsername(userName);
metaBinding.setPassword(password);
metaBinding.describeMetadata(); // >> INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
Thanks.
binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
loginResult = binding.login(userName, password);
SessionHeader sh = new SessionHeader();
sh.setSessionId(loginResult.getSessionId());
metaBinding = (MetadataBindingStub) new MetadataServiceLocator().getMetadata();
metaBinding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY,
loginResult.getMetadataServerUrl());
metaBinding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(),
"SessionHeader", sh);
metaBinding.describeMetadata(); // INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
I've also tried
metaBinding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY,
loginResult.getServerUrl());
and I get
>> No operation available for request {http://soap.sforce.com/2006/04/metadata}describeMetadata
There's a metadataServerUrl on LoginResult to get the url to the metadata API.
I mentioned that I've tried both getServerUrl() and getMetadataServerUrl(). I showed the two different error messages depending on which one I use.
Is that what you meant, or is there some other call I should be making?
I appreciate your help. Thanks.
loginResult = binding.login(userName, password);
SessionHeader sh = new SessionHeader();
sh.setSessionId(loginResult.getSessionId());
metaBinding = (MetadataBindingStub) new MetadataServiceLocator().getMetadata();
metaBinding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY,
loginResult.getMetadataServerUrl());
metaBinding.setHeader(new MetadataServiceLocator().getServiceName().getNamespaceURI(),
"SessionHeader", sh);
metaBinding.describeMetadata();
public final class Test {
public static void main(String[] args) {
String userName = "";
String password = "";
MetadataServiceLocator metaDataSL = new MetadataServiceLocator();
SforceServiceLocator salesForceSL = new SforceServiceLocator();
try {
SoapBindingStub soapBinding = (SoapBindingStub) salesForceSL.getSoap();
soapBinding.setTimeout(60000);
LoginResult loginResult = soapBinding.login(userName, password);
SessionHeader sh = new SessionHeader();
sh.setSessionId(loginResult.getSessionId());
MetadataBindingStub metaBinding = (MetadataBindingStub) metaDataSL.getMetadata();
metaBinding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY,
loginResult.getMetadataServerUrl());
metaBinding.setHeader(metaDataSL.getServiceName().getNamespaceURI(),
"SessionHeader", sh);
System.out.println(metaBinding.describeMetadata());
} catch (Exception e) {
e.printStackTrace();
}
}
}
the above code was very helpful...
i am facing the following issue when i use the delete method of metadata...
metadatabinding.delete(plMetadata); ----> java.io.IOException: No serializer found for class com.sforce.soap.enterprise.SessionHeader in registry org.apache.axis.encoding.TypeMappingDelegate@1eb8f6d
code used for binding:::
SessionHeader sessionHeader = new SessionHeader();
sessionHeader.setSessionId(loginResult.getSessionId());
SforceServiceStub stub = new SforceServiceStub(loginResult.getServerUrl());
log.info("Connected to SF with the URL: " + endPointURL);
metadatabinding = (MetadataBindingStub) new MetadataServiceLocator().getMetadata();
metadatabinding._setProperty(MetadataBindingStub.ENDPOINT_ADDRESS_PROPERTY, loginResult.getMetadataServerUrl());
metadatabinding.setHeader(new MetadataServiceLocator().getServiceName().getNamespaceURI(),
"SessionHeader", sessionHeader);
metadatabinding.delete(plMetadata); ----> java.io.IOException: No serializer found for class com.sforce.soap.enterprise.SessionHeader in registry org.apache.axis.encoding.TypeMappingDelegate@1eb8f6d
TIA :) ,
Umar
You need to use the SessionHeader class from the metadata wsdl/package, you're using the one from the enterprise wsdl/package.
Hi
I have a problem .
I generate metadata.jar and enterprise.jar from Wsc-20.jar .But these jars do not contain
MetadabindingStub,
MetadataServiceLocator,
SoapBindingStub
SforceServiceLocator
SessionHeader classes . How can I get these Clases .
Please Help me its urgent...............................