Closed GoogleCodeExporter closed 8 years ago
After some more investigation I've found a work-around to this issue. Since the
metadata API doesn't have its own login operation, I first login to the partner
service, and use the session id obtained from that call to invoke metadata
operations.
I'm not sure if this approach is optimal, but it would be nice if the generated
metadata stubs could be enhanced to do this (or similar behavior).
Sample code is attached...
Original comment by turntwo...@gmail.com
on 16 Jun 2009 at 7:14
Attachments:
Thanks for the sample. You are doing the right thing. There is no login call on
metadata wsdl. You need to login using partner wsdl to get the session id.
Original comment by manoj.ch...@gmail.com
on 19 Jun 2009 at 10:44
[deleted comment]
The sample can be simplified a bit without hacking the URL. Set the Session Id
at for a new connector config and pass that to the metadata connection.
ConnectorConfig partnerConfig = new ConnectorConfig();
partnerConfig.setUsername("un");
partnerConfig.setPassword("pw");
partnerConfig.setTraceMessage(true);
PartnerConnection partnerConn = com.sforce.soap.partner.Connector.newConnection(partnerConfig);
System.out.println("Partner Session Id: " + partnerConn.getSessionHeader().getSessionId());
System.out.println("Partner Endpoint: " + partnerConn.getConfig().getServiceEndpoint());
ConnectorConfig metaConfig = new ConnectorConfig();
metaConfig.setSessionId(partnerConn.getSessionHeader().getSessionId());
MetadataConnection metaConn = Connector.newConnection(metaConfig);
System.out.println("Metadata Session Id: " + metaConn.getSessionHeader().getSessionId());
System.out.println("Endpoint: " + metaConn.getConfig().getServiceEndpoint());
Original comment by naamanne...@gmail.com
on 8 Jul 2010 at 6:34
Rather creating metadata URL, I guess simpler solution can be to use
metadataServerUrl from Partner Login result. Sample code shown below
ConnectorConfig partnerConfig = new ConnectorConfig();
// IMPORTANT : This will not let PartnerConnection do the login
partnerConfig.setManualLogin(true);
PartnerConnection partnerConnection =
com.sforce.soap.partner.Connector.newConnection(partnerConfig);
LoginResult lr = partnerConnection.login(USERNAME, PASSWORD);
ConnectorConfig metadataConfig = new ConnectorConfig();
metadataConfig.setSessionId(lr.getSessionId());
metadataConfig.setServiceEndpoint(lr.getMetadataServerUrl());
MetadataConnection metadataConnection =
com.sforce.soap.metadata.Connector.newConnection(metadataConfig);
DescribeMetadataResult describeMetadata =
metadataConnection.describeMetadata(API_VERSION);
System.out.println(describeMetadata);
Original comment by abhinavgupta697
on 27 Jul 2010 at 9:31
@naamannewbold I tried your code it didn't worked and failed for invalid
session Id. So I tried digging the stuff and found the solution I suggested in
previous comment.
Original comment by abhinavgupta697
on 27 Jul 2010 at 9:35
Original issue reported on code.google.com by
turntwo...@gmail.com
on 16 Jun 2009 at 5:01Attachments: