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
BaloodevilBaloodevil 

No operation available for request {http://soap.sforce.com/2006/04/metadata} ...

I am trying to get the sample code here working.

 

The section in the source code that says...

 

 

 

 

      /*  Once the client application has logged in successfully, we use 
       *  the results of the login call to reset the endpoint of the service  
       *  to the virtual server instance that is servicing your organization.  
       *  To do this, the client application sets the ENDPOINT_ADDRESS_PROPERTY 
       *  of the binding object using the URL returned from the LoginResult. We
       *  use the metadata binding from this point forward as we are invoking
       *  calls in the metadata WSDL.
       */  
    
      metadataConnection = new MetadataConnection(config);
      /*
      metadataConnection._setProperty(MetadataBindingStub.ENDPOINT_ADDRESS_PROPERTY,
              loginResult.getMetadataServerUrl());
              */  

 

Doesn't seem to be correct.  From the error "No operation available for request {http://soap.sforce.com/2006/04/metadata} retrieve" I've found that none of the operations associated with a MetadataConnection work.  And I found that because the bottom part of the code above is commented out, the ServiceEndpoint for the MetadataConnection is the same as the ServiceEndpoint of the Connection (used for synchronous stuff).  I'm guessing this is incorrect.  It seems that the two endpoints should be different, but according to the sample code listed on salesforce's website, they are the same.  

 

If I try to uncomment the above code, it throws errors because MetadataBindingStub is not found (presumably it should be in the jars generated from the WSDLs for which I used WSC).  Other articles talk about setting the metadata service endpoint from a field on the LoginResult of the same name, but perhaps that is from older versions of the API, or another jar from WSDL generator?  Would using the JAX-WS instead of WSC solve this?  I'm lost here.

 

 

 

BaloodevilBaloodevil

What is an example of the ServiceEndpoint value of a MetadataConnection?

SuperfellSuperfell

Hmmm, yeah, that's a weird mix of wsc & axis, I'll log a bug to get that fixed. 

 

Here's working sample that does login & then describeMetadata

 

 

public class ListMetadata {

	public static void main(String[] args) throws ConnectionException {
		ListMetadata md = new ListMetadata();
		md.login(args[0], args[1]);
		md.listMetadata();
	}

	private MetadataConnection metadataStub;
	
	public void login(String username, String password) throws ConnectionException {
		ConnectorConfig cfg = new ConnectorConfig();
		cfg.setManualLogin(true);
		PartnerConnection pc = Connector.newConnection(cfg);
		LoginResult lr = pc.login(username, password);
		
		ConnectorConfig mdCfg = new ConnectorConfig();
		mdCfg.setSessionId(lr.getSessionId());
		mdCfg.setServiceEndpoint(lr.getMetadataServerUrl());
		metadataStub = new MetadataConnection(mdCfg);
	}
	
	public void listMetadata() throws ConnectionException {
		DescribeMetadataResult d = metadataStub.describeMetadata(21.0);
		for (DescribeMetadataObject m : d.getMetadataObjects())
			System.out.println(m.getXmlName());
	}
}