Axis2 with MapPoint 4.5 Java?

trowland
05-30-2007, 08:57 AM
Is MapPoint 4.5 compatible with Axis2? I cannot seem to generate all of the classes using wsdl2java. For example,

MapPoint 3.0 with Axis 1.2 produced:
RenderService.java
RenderServiceLocator.java
RenderServiceSoap.java
RenderServiceSoapStub.java

MapPoint 4.5 with Axis2 produces:
RenderService.java
RenderServiceCallbackHandler.java
RenderServiceMessageReceiverInOut.java
RenderServiceSkeleton.java
RenderServiceStub.java

I have also found other differences, e.g. Format.setHeight(Integer) is now format.setHeight(int), and several others similarly. Is it correct that MapPoint 4.1 is fully backward-compatible but 4.5 is not?

Thank you
Tom
thomas.rowland@priceline.com

trowland
06-08-2007, 11:30 AM
Yes mappoint 4.5 works fine with axis2. The mappoint types are generated as inner classes to the stub. You access everything through the stub. Generating the Java classes is almost the same as in axis1, except axis2 provides a .bat file you can use, and also some of the switch parameters are slightly different.

Here is an example of generating the class files using ADB. You can also use JIBX or XMLBeans if you wish - let me know how that works out! Also make sure you also have all of the jar files in your classpath:

wsdl2java -uri http://staging.mappoint.net/standard-30/mappoint.wsdl -ns2p http://s.mappoint.net/mappoint-30/=com.myapp.mapmanager.mappoint_45, http://s.mappoint.net/v40/=com.myapp.mapmanager.mappoint_45 -o .\mp45classfiles -g -t -wv 1.1 -d adb -ssi

This creates the following files:

CommonServiceCallbackHandler.java
CommonServiceStub.java
FindServiceCallbackHandler.java
FindServiceStub.java
RenderServiceCallbackHandler.java
RenderServiceStub.java
RouteServiceCallbackHandler.java
RouteServiceStub.java

You only need to use the stubs unless you are using asynch then you want to also make use of the callback handlers.

Here is an example of using the RenderServiceStub to call the GetMap() method on a GetMap object:

/*************************************
* create your MapSpecification obj
************************************/
MapSpecification spec = new MapSpecification();
spec.setViews(aViews);
spec.setDataSourceName("MapPoint.NA");
spec.setOptions(options);
spec.setPushpins(aPushpins);

/*************************************
* the Stub
************************************/
RenderServiceStub stub = new RenderServiceStub();

/**************************************
* Authenticator
************************************/
HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
auth.setUsername(MapManagerParams.getUsername());
auth.setPassword(MapManagerParams.getPassword());
auth.setPreemptiveAuthentication(true);

/**************************************
* ServiceClient options
************************************/
Options options = stub._getServiceClient().getOptions();
options.setProperty(HTTPConstants.AUTHENTICATE, auth);
options.setProperty(HTTPConstants.SO_TIMEOUT, new Integer(90000));
options.setProperty(HTTPConstants.CONNECTION_TIMEO UT, new Integer(90000));

// make sure we are using HTTP 1.0 and not 1.1
options.setProperty( org.apache.axis2.context.MessageContextConstants.H TTP_PROTOCOL_VERSION,
org.apache.axis2.transport.http.HTTPConstants.HEAD ER_PROTOCOL_10);

//-- set the EndpointReference (the RenderServicURL)
EndpointReference endpoint = new EndpointReference(sEndpoint);
options.setTo(endpoint);

/*************************************
* GetMap object
************************************/
RenderServiceStub.GetMap getMap = new RenderServiceStub.GetMap();
getMap.setSpecification(spec);

/*************************************
* CustomerInfoRenderHeader
************************************/
CustomerInfoRenderHeader custInfoRenderHeader = new CustomerInfoRenderHeader();
custInfoRenderHeader.setCustomLogEntry((short) 20);

CustomerInfoRenderHeader0 custInfoRenderHeader0 = new CustomerInfoRenderHeader0();
custInfoRenderHeader0.setCustomerInfoRenderHeader( custInfoRenderHeader);

/*************************************
* UserInfoRenderHeader
************************************/
UserInfoRenderHeader userInfoRenderHeader = new UserInfoRenderHeader();
userInfoRenderHeader.setDefaultDistanceUnit(Distan ceUnit.Mile);
// CultureInfo
CultureInfo cult = new CultureInfo();
// cultureInfo.setLcid(5);
cult.setName("en-us"); // default is en-US
userInfoRenderHeader.setCulture(cult);
// countryRegionContext
CountryRegionContext ctx = new CountryRegionContext();
ctx.setEntityID(244);
userInfoRenderHeader.setContext(ctx);
UserInfoRenderHeader6 userInfoRenderHeader6 = new UserInfoRenderHeader6();
userInfoRenderHeader6.setUserInfoRenderHeader(user InfoRenderHeader);

/*************************************
* Send the Request
************************************/
GetMapResponse mapResponse =
stub.GetMap(getMap,custInfoRenderHeader0,userInfoR enderHeader6);

/*************************************
* get the images from the Response
************************************/
ArrayOfMapImage aImages = mapResponse.getGetMapResult();
MapImage[] images = aImages.getMapImage();


The above shows that working with the stubs and the ServiceClient are quite different using axis2, however working with the mappoint api has only changed slightly. E.g. the method params that used to be objects are now primitives, e.g.:
pushpins[0].getLatLong().setLatitude(new Double(42.264779115928796));
is now
pushpins[0].getLatLong().setLatitude(42.264779115928796);
Another difference in the mappoint api is that every service method requires a userInfoHeader and customerInfoHeader param. Look at my code above to see how these are set - it tripped me up!

One other difference in using axis2 was that there is no longer a client-config.wsdd. I have set those params programmatically here, but you can also use an axis2.xml file in its place.

Here are some references that may help you with axis2:

Axis2/Java - Axis2 Reference Guide (http://ws.apache.org/axis2/1_2/reference.html)
Axis2/Java - Migrating from Axis 1.x (http://ws.apache.org/axis2/1_2/migration.html)
Apache Axi2/Java | WSO2 Oxygen Tank (http://wso2.org/projects/axis2/java)
Axis2 FAQ (http://docs.huihoo.com/apache/axis2-1.0-docs/xdocs/faq.html)


thanks,
Your experiences/feedback are much appreciated!
Tom
thomas.rowland@priceline.com

 
Web mp2kmag.com
mapforums.com