Created
August 28, 2014 15:26
-
-
Save Alan01252/5f9d260ef1682a661a0e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.microsoft.schemas._2003._10.serialization.arrays.ArrayOfstring; | |
import com.microsoft.schemas.xrm._2011.contracts.ColumnSet; | |
import com.microsoft.schemas.xrm._2011.contracts.EntityCollection; | |
import com.microsoft.schemas.xrm._2011.contracts.OrganizationService; | |
import com.microsoft.schemas.xrm._2011.contracts.QueryByAttribute; | |
import com.microsoft.schemas.xrm._2011.contracts.services.IOrganizationService; | |
import org.apache.cxf.Bus; | |
import org.apache.cxf.endpoint.Client; | |
import org.apache.cxf.endpoint.EndpointImpl; | |
import org.apache.cxf.frontend.ClientProxy; | |
import org.apache.cxf.interceptor.security.NamePasswordCallbackHandler; | |
import org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry; | |
import java.net.URL; | |
import javax.security.auth.callback.CallbackHandler; | |
class app { | |
public static void main(String[] args) throws Exception { | |
String krb = "krb5.conf"; | |
String login = "login.conf"; | |
System.setProperty("java.security.auth.login.config", login); | |
System.setProperty("java.security.krb5.conf", krb); | |
final String username = "username"; | |
final String password = "******"; | |
String spn = "RestrictedKrbHost/internalcrm.example.co.uk"; | |
String jassClient = "spnego-client"; | |
CallbackHandler callbackHandler = new NamePasswordCallbackHandler(username, password); | |
URL | |
wsdlLocation = | |
new URL("https://internalcrm.6dgdev.co.uk:444/XrmServices/2011/Organization.svc?wsdl"); | |
OrganizationService service = new OrganizationService(wsdlLocation); | |
IOrganizationService port = service.getCustomBindingIOrganizationService(); | |
Client client = ClientProxy.getClient(port); | |
Bus bus = ((EndpointImpl) client.getEndpoint()).getBus(); | |
PolicyInterceptorProviderRegistry | |
pipr = bus.getExtension(PolicyInterceptorProviderRegistry.class); | |
pipr.register(new XRMAuthPolicyProvider()); | |
client.getRequestContext().put("ws-security.sts.client-soap12-binding", "true"); | |
client.getRequestContext().put("ws-security.sts.client-allowRenewing", "false"); | |
client.getRequestContext().put("ws-security.sts.client-location", "https://internalcrm.6dgdev.co.uk:444/XrmServices/2011/Organization.svc?wsdl"); | |
client.getRequestContext().put("ws-security.kerberos.jaas.context", jassClient); | |
client.getRequestContext().put("ws-security.kerberos.spn", spn); | |
client.getRequestContext().put("ws-security.callback-handler", callbackHandler); | |
client.getRequestContext().put("ws-security.spnego.client.action", new XRMSpnegoClientAction()); | |
ColumnSet columnSet = new ColumnSet(); | |
columnSet.setAllColumns(true); | |
columnSet.setColumns(new ArrayOfstring()); | |
QueryByAttribute qba = new QueryByAttribute(); | |
qba.setEntityName("account"); | |
qba.setColumnSet(columnSet); | |
EntityCollection entityCollection = port.retrieveMultiple(qba); | |
System.out.println(entityCollection); | |
} | |
} |
You can generate them from WSDL using wsdl2java tooling.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Have you found any solution? i still don't find these jar files.