AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
DAX
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 20.01.2010, 01:09   #1  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Регистрация: 28.10.2006

Prerequisites
Please read this post to get an explanation on how to modify the service tier to use NTLM authentication and for a brief explanation of the scenario I will implement in Java.

BTW. Basic knowledge about Java is required to understand the following post:-)


Version and download
Java does not natively have support for the SPNEGO authentication protocol, but it does have support for NTLM authentication, so you will have to change the Web Services listener to use that.

I downloaded the Java developer toolkit from http://www.java.com/en/download/manual.jsp and installed it under c:sun – and made sure that c:sunSDKbin is added to the path.


wsimport – import WSDL
To make Java able to see and use webservices I use wsimport to create proxy classes in Java. In a directory, I have created two empty folders (generated and source) and use the following command:

C:java>wsimport -d generated -s source http://localhost:7047/DynamicsNAV/WS/SystemService

this will create a series of .class files under

C:javageneratedschemasdynamicsmicrosoftnavsystem

and a set of source files under

C:javasourceschemasdynamicsmicrosoftnavsystem

note, that the folder structure is the namespace of the web service.


javac – compile the program
Assuming that I create a test program in c:javatest.java, the following command will compile the program:

c:java>c:sunsdkjdkbinjavac -cp .;generated test.java

this creates a c:javatest.class, which we can run.


java – run the program
The statement used to run the java class is:

c:java>c:sunsdkjdkbinjava -cp .;generated test

enough about setup – lets code…


Authentication
By default, java supports Windows Authentication and if the class is running in context of a windows user, these credentials are automatically used to authenticate towards NAV Web Services.

If you want to use different credentials (connect as a different user) you will need to create a class derived from Authenticator and implement getPasswordAuthentication like:

static class MyAuthenticator extends Authenticator {
  public PasswordAuthentication getPasswordAuthentication() {
    return (new PasswordAuthentication("domainuser", new char[] {'p','a','s','s','w','o','r','d'}));
  }
}


and then as the very first statement in the class

Authenticator.setDefault(new MyAuthenticator());


test.java
First of all, I have a number of imports. Not sure that they all are needed and then a main function body:

import java.net.*;
import java.util.*;
import java.io.*;
import javax.xml.namespace.QName;
import schemas.dynamics.microsoft.nav.system.*;
import schemas.dynamics.microsoft.page.customer.*;


public class test {
    public static void main(String[] args) {


        // main program code

    }
}


The main code is:



try {
 
String baseURL = "
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 


Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 02:08.