Connecting Microsoft Dynamics GP10 web services – using Java


Use the  below java code to connect MS dynamics GP10


import java.net.URL;

import java.rmi.RemoteException;

import java.util.Hashtable;

import java.io.File;

import java.io.FileInputStream;

import java.io.IOException;

import java.net.MalformedURLException;

import java.net.URL;

import java.rmi.RemoteException;

import java.util.Hashtable;

import java.util.Properties;

import org.apache.axis.SimpleTargetedChain;

import org.apache.axis.client.AxisClient;

import org.apache.axis.configuration.SimpleProvider;

import org.apache.axis.transport.http.CommonsHTTPSender;

import org.apache.log4j.Logger;

import javax.naming.Context;

import javax.naming.InitialContext;

import javax.xml.namespace.QName;

import javax.xml.rpc.ServiceException;

import com.microsoft.schemas.dynamics._2006._01.CompanyKey;

import com.microsoft.schemas.dynamics._2006._01.CurrencyType;

import com.microsoft.schemas.dynamics._2006._01.OrganizationKey;

import com.microsoft.schemas.dynamics.gp._2006._01.CurrencyKey;

import com.microsoft.schemas.dynamics.gp._2006._01.Dynamics_x0020_GPLocator;

import com.microsoft.schemas.dynamics.gp._2006._01.Dynamics_x0020_GPSoap;

import com.microsoft.schemas.dynamics.gp._2006._01.GetInventoriedItemByKey;

import com.microsoft.schemas.dynamics.gp._2006._01.Item;

import com.microsoft.schemas.dynamics.gp._2006._01.ItemCriteria;

import com.microsoft.schemas.dynamics.gp._2006._01.ItemKey;

import com.microsoft.schemas.dynamics.gp._2006._01.ItemSummary;

import com.microsoft.schemas.dynamics.gp._2006._01.LikeRestrictionOfString;

import com.microsoft.schemas.dynamics.gp._2006._01.Service;

import org.apache.axis.client.Stub;

public class GPConnect {

public static void main(String args[]) {

String endpoint = “http://xxxx:PORT/DynamicsGPWebServices/DynamicsGPService.asmx”;

String username=”domain\\xxxx”;

String password = “xxxxx”;

CompanyKey companyKey = null;

String currencyType = “Transactional”;

String cultureName = “en-US”;

String portNumber = “”;

String roleKey = null;

Dynamics_x0020_GPSoap stub;

com.microsoft.schemas.dynamics.gp._2006._01.Dynamics_x0020_GPLocator locator = new Dynamics_x0020_GPLocator();

locator.setDynamics_x0020_GPSoap12EndpointAddress(endpoint);

com.microsoft.schemas.dynamics._2006._01.Context context= new com.microsoft.schemas.dynamics._2006._01.Context();

try {

stub = locator.getDynamics_x0020_GPSoap12();

((Stub)stub).setUsername(username);

((Stub)stub).setPassword(password);

Hashtable headers = new Hashtable();
headers.put(“chunked”, “false”);
headers.put(“Connection”,”keep-alive”);
((Stub)stub)._setProperty(“HTTP-Request-Headers”, headers);
System.out.println(“StubCreated”);

ItemCriteria criteria= new ItemCriteria();
LikeRestrictionOfString itemClassId= new LikeRestrictionOfString();
itemClassId.setEqualValue(“CATALOG”);
criteria.setItemClassId(itemClassId)

context.setCultureName(“en-US”);
CurrencyType cuType = new CurrencyType(“Transactional”);
context.setCurrencyType(cuType);
companyKey = new CompanyKey();
companyKey.setId(-1);

OrganizationKey orgkey=(OrganizationKey)companyKey;
context.setOrganizationKey(orgkey);
ItemKey key = new ItemKey(“128 SDRAM”);
Item o = stub.getItemByKey(key , context);
System.out.println(o.getDescription());

} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printmessage()
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printmessage()
}
}
}

 


Thanks for reading this article!! please leave your comments and suggestion about this article.

Advertisements

How to connect Microsoft Dynamics GP using API methods






The following are the types to integrate Microsoft Dynamics GP  from other Applications


1. Component Object Model (COM) API


             Using the COM dll ,  develop Visual studio application for the integration.

2. eConnect

            eConnect is a collection of tools, components, and interfaces that allow applications to pro grammatically interact with Microsoft Dynamics GP. eConnect interfaces allow external applications to integrate with Microsoft Dynamics GP. The external applications can perform actions like creating, updating, retrieving, and deleting back office documents and transactions. 


An eConnect integration also reduces costs by reducing data re-entry

3. Integration Manager
        
           Integration manager  is  an integration tool used to convert and transfer data other application in to Microsoft Dynamics GP.(Trial Version – 90 days)
4. Dynamics GP Web Services
        
           Using web services able to convert and transfer data to other application(vice versa).Also through Web services management console user data access can be restricted.

Behind web services , eConnect API is used to integrate with Dynamics GP.






Setting up Functional Currency in Microsoft Dynamics GP for Web services


 To access a Company in Microsoft Dynamics GP we have to set up  the functional currency for the web services access.Also Dynamics GP web service uses ISO codes to identify currencies in Microsoft
Dynamics GP.
 
Note: Logon into the Company in Microsoft Dynamics GP to set up functional currency.
 
 
 
 
 
 
To add functional currency , complete the following procedure:
 1.  Open the Functional Currency Setup window in Microsoft Dynamics GP.

          Choose Microsoft Dynamics GP menu >> Tools >> Setup >> Functional>>
          MultiCurrency and enter the system password to display this window.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2.  A Window appear as below:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3. Display each currency.
            Use the Currencies lookup to display each currency.
            Press (Ctrl + L) or click the search icon to display the below window.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4. Select the Currency to set the ISO code.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5. Set the Default Transaction types.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 6. Save and Exit.
After entering the Currency Click OK and close the window.
 
Now the Functional Currency set up is finished for the Company and able to access through GP web services.
 

Setting up Currency ISO Code in Microsoft Dynamics GP


The Dynamics GP web service uses ISO codes to identify currencies in Microsoft
Dynamics GP.
Note: Web Services for Microsoft Dynamics GP does not support using the same ISO code for more than one currency.
To add ISO codes, complete the following procedure:
 1.  Open the Currency Setup window in Microsoft Dynamics GP.
          Choose Microsoft Dynamics GP menu >> Tools >> Setup >> System >>
          Currency and enter the system password to display this window.

 2. Display each currency.
            Use the Currencies lookup to display each currency.
            Press (Ctrl + L) or click the search icon to display the below window.

3. Select the Currency to set the ISO code
    
        For e.g. select US Dollars, the Following window appears.
4. Enter the ISO value and save the currency.
Enter the code in the ISO Code Text Field.
The following table lists the ISO values for the currencies commonly defined in
Microsoft Dynamics GP:
ISO Code
Country/Region
Currency
USD
United States
Dollars
AUD
Australia
Dollars
CAD
Canada
Dollars
EUR
European Union
Euros
JPY
Japan
Yen
MXN
Mexico
Pesos
SGD
Singapore
Dollars
NZD
New Zealand
Dollars
 5. Save and Exit.
After entering the ISO code save the Currency and close the window.


Now the Currency set up is finished and able to access through GP web services.