[JBossWS] - JAX-WS Web Service Authentication (NTLM) against a MS CRM Se
by ivan.stefanov
Hello everybody,
I am currently developing a jboss web service client, which is supposed to connect to a web service on a Microsoft CRM Dynamics (I hope I've got the name right) instance, running on an Internet Information Server. The service itself and the relevant data types are defined in a what appears to be a standard CrmServiceWsdl.aspx file.
I've generated the Java classes with the /bin/wsconsume.bat tool in the JBoss folder. We have many times used this tool successfully, when programming JBoss web services and clients for them. Everything seemed nice and well, the client easily connected (including HTTP BASIC authentication) and sent what looked like a correct request to a dummy JBoss web service which I wrote for testing purposes. The problems appeared when we tried the real thing, namely connecting to the MS CRM web service. The IIS Server has the "Windows Intergrated Security" authentication activated, which is supposed to be NTLM.
First I have tried doing HTTP Basic, as the IIS was also supposed to support it:
| url = new java.net.URL(InfondsParameter.CRMWebServiceUrlCreateUpdateTask.get(em));
|
| CrmTaskServiceSoap port = (new CrmTaskService(url, new QName("http://schemas.microsoft.com/crm/2007/WebServices", "CrmService")))
| .getCrmTaskServiceSoap();
| ((BindingProvider)port).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "username");
| ((BindingProvider)port).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "password");
|
This didn't work and I kept getting the "javax.xml.ws.WebServiceException: org.jboss.ws.WSException: Target endpoint address not set" error message plus debug messages (my own) telling me the WSDL could not be reached.
Then I decided to aim for the NTLM authentication. Following advice I found on many (non official) sources in Internet, I wrote the following:
| static class MyAuthenticator extends Authenticator {
|
| private String user;
| private String pass;
|
| public MyAuthenticator(String user, String pass) {
| this.user = user;
| this.pass = pass;
| }
|
| public PasswordAuthentication getPasswordAuthentication() {
| return (new PasswordAuthentication(kuser, kpass.toCharArray()));
| }
| }
|
| public static void callCreateTask()
|
| Authenticator.setDefault(new MyAuthenticator("username", "password"));
|
| url = new java.net.URL(InfondsParameter.CRMWebServiceUrlCreateUpdateTask.get(em));
|
| CrmTaskServiceSoap port = (new CrmTaskService(url, new QName("http://schemas.microsoft.com/crm/2007/WebServices", "CrmService")))
| .getCrmTaskServiceSoap();
|
| ...
|
| String ret = port.create(ent);
| }
|
Now the WSDL seems to get reached and consumed, but at the last row I still get a "org.jboss.ws.WSException: Invalid HTTP server response [401] - Unauthorized". The port.create(ent) statement is just calling the "create" operation, defined in the WSDL, with the argument being an entity, also as defined in the WSDL.
I really fail to grasp what is going wrong. As far as I know, Java is supposed to support NTLM Authentication "off the shelf" through the Authenticator class and it obviously does some work, as the WSDL residing on the IIS could be opened and read. However, the call to the service itself could not be authorised. I've found some references to a CrmAuthenticationToken having to be set, but neither my CrmTaskService (which is the standard CrmService), nor CrmTaskServiceSoap (which is the proxy of the service) has been generated with a possibility to set Credentials or AuthenticationToken.
Has anyone had exprience with interfacing the Microsoft CRM Web Services? Any advice, insight or ideas are welcome!
Thank you in advance!
Best regards,
Ivan Stefanov
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250438#4250438
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250438
15 years, 4 months
[JBossWS] - Problem installing jbossws-native-3.1.1.GA onto jboss-4.2.3.
by jse
Hi
I have a problem with my installation of jbossws 3.1.1 over the top of jboss 4.2.3.GA. I get this error:
| 2009-08-19 14:53:36,920 ERROR [org.jboss.deployment.MainDeployer] Could not start deployment: file:/app/jboss-4.2.3.GA/server/fred/tmp/deploy/tmp32687FRED.ear-contents/FRED.war
| java.lang.IllegalStateException: Failed to load org.jboss.wsf.spi.invocation.WebServiceContextFactory: org.jboss.wsf.container.jboss42.WebServiceContextFactoryImpl
| at org.jboss.wsf.spi.util.ServiceLoader.loadFromServices(ServiceLoader.java:97)
| ...
| lots of lines
| ...
| at java.lang.Thread.run(Unknown Source)
| Caused by: java.lang.NoClassDefFoundError: org/jboss/wsf/spi/invocation/WebServiceContextEJB
| at java.lang.Class.getDeclaredConstructors0(Native Method)
| at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
| at java.lang.Class.getConstructor0(Unknown Source)
| at java.lang.Class.newInstance0(Unknown Source)
| at java.lang.Class.newInstance(Unknown Source)
| at org.jboss.wsf.spi.util.ServiceLoader.loadFromServices(ServiceLoader.java:92)
|
Looking at the jbossws-native-3.1.1.GA binary distribution it appears that there is no class org.jboss.wsf.spi.invocation.WebServiceContextEJB. It is not contained within jbossws-spi.jar.... although jbossws-native-core.jar does contain org.jboss.wsf.stack.jbws.WebServiceContextEJB
I can see this class in the jbossws-spi.jar for a jboss 4.2.3 that has not been "upgraded" with jbossws-native-3.1.1
The classes in FRED.war were built using the ws*.bat scripts/code that shipped with the jbossws shipped with Jboss 4.2.3.GA. Not sure if this is relevant.
Any advice gratefully received.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250417#4250417
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250417
15 years, 4 months