none
Accessing Bing Maps Web Services using Java RRS feed

All replies

  • I don't use Java myself, but this looks like really useful information for anybody that does - thanks for sharing it.

    Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
    Tuesday, September 8, 2009 6:16 PM
    Moderator
  • Hi,

    I have a quick question,

    I can't seem to find the "net.virtualearth.dev.webservices.v1.common.*;

    What WSDL generates this?.

    I have the stubs generated for following four WSDL's.
    Common/Token : https://staging.common.virtualearth.net/find-30/common.asmx?wsdl
    Geocode Service : http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc?wsdl
    Imagery Service : http://dev.virtualearth.net/webservices/v1/imageryservice/imageryservice.svc?wsdl
    Route Service : http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc?wsdl
    Search Service : http://dev.virtualearth.net/webservices/v1/searchservice/searchservice.svc?wsdl

    Thursday, October 1, 2009 6:31 PM
  • I think you have the wrong WSDL urls.  Here's what I'm using for the geocode service:

    http://staging.dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc?wsdl
    Friday, October 2, 2009 12:20 AM
  • Which URL you use depends on whether you are accessing the staging or production environment. The service URLs srrk listed are for the production environment. The staging environments are all proceeded by a "staging" subdomain. Since you are using a staging token, you will need the staging service URL as orbitphreak listed.


    Friday, October 2, 2009 12:23 AM
  • Thanks.

    That helped.
    Friday, October 2, 2009 3:38 PM
  • hi, I found problems on generating stubs. This is what I used,
    java org.apache.axis.wsdl.WSDL2Java -U 147281 -P 2009Transit* https://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc?WSDL

    but exceptions are throwed out,
    org.xml.sax.SAXException: Fatal Error: URI=null Line=1: Premature end of file.
        at org.apache.axis.utils.XMLUtils$ParserErrorHandler.fatalError(XMLUtils.java:723)
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
    ...

    It works for the common services...though, I don't know why here. Any ideas on what happened here? I am quite new to web service development, and really appreciate your help
    Saturday, November 14, 2009 10:32 PM
  • Check out this thread: http://social.msdn.microsoft.com/Forums/en-US/vemapcontroldev/thread/7e73e1a2-2d06-4065-bc51-011d35553e61
    Windows Live Developer MVP - http://rbrundritt.spaces.live.com
    Saturday, November 14, 2009 11:19 PM
  • Thanks for the update. I have successfully translate the wsdl into java files. But it seems there are still problems in the auto-generated files, net.virtualearth.dev.webservices.v1.common.ResponseSummary" can not be recognized as Throwable.

    Btw, the system is  ubuntu and jdk1.6. Is there any one who encountered the same problem? Any help is appreciated , thankx
    Sunday, November 15, 2009 1:59 AM
  • Jonathan

     

    Thanks for you blog at the above link, I was able to do a lot of progresss. here is my new problem

    Hi

    I started writing java based web services using axis.jar(probably older version..NOT axis2). I am using keys. I used wsdl2java from axis .jar to create the stub classes. below is the code and it worked fine....

       BasicHttpBinding_IGeocodeServiceStub geocodeServiceClient = (BasicHttpBinding_IGeocodeServiceStub) (new GeocodeServiceLocator()).getBasicHttpBinding_IGeocodeService();
       GeocodeRequest request = new GeocodeRequest();

    ..........................


    Now I am ready to write ANT scripts and took axis2 instead of axis. The ant task using axis2 generate lot of other classes and does not have some of the older classes I had generated. I am getting compile errors on all my web service code.

    I looking for JAVA based web service code for geocode and route. I cannot resolve the compile errors.  BasicHttpBinding_IGeocodeServiceStub is no longer available in the new set of generated classes.

    Could you explain.

    Wednesday, June 16, 2010 4:53 PM
  • The Axis2 library is totally different from Axis. If you use an IDE like Eclipse, you should get the suggestions dropdown for the available methods. I'll pull up some of my examples and post them up.
    Wednesday, June 16, 2010 9:47 PM
  • Hello Jonathan,

    I am using the Imagery Srvices GetMapUri to get the uri, and then I use that uri to get the image.

    I am getting an Invalid URL exception when I use that uri to do HttpClient.execute(GetMethod), but when I use the same from a browser it works ? Am I missing anythign here ? Would you know.

     

    thanks

    sdt_dev

    Saturday, October 9, 2010 7:48 PM
  • Hi Jonathan,

    I have used axis2 to generate the proxy and binding files. as mentioned above now I dont see  BasicHttpBinding_IGeocodeServiceStub etc.. classes. While trying to populate request with axis2 I am getting following error:

    Exception in thread "main" org.apache.axis2.AxisFault: Transport error: 415 Error: Cannot process the message because the content type 'application/soap+xml; charset=UTF-8; action="http://dev.virtualearth.net/webservices/v1/geocode/contracts/IGeocodeService/Geocode"' was not the expected type 'text/xml; charset=utf-8'.
        at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:298)
        at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:192)
        at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:77)
        at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:327)
        at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:206)
        at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:396)
        at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:374)
        at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
        at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
        at com.fedex.xmlns.iit.Bing.services.GeocodeServiceStub.Geocode(GeocodeServiceStub.java:207)
        at TestBingMaps.main(TestBingMaps.java:16)

     

    I have created following request:

    public static void main(String[] args) throws Exception {
            GeocodeServiceStub geocodeService = new GeocodeServiceStub("http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc");
            //GeocodeServiceStub stub = new GeocodeServiceStub();
            GeocodeResponseDocument response = geocodeService.Geocode(getGeocodeDocument());
    //       
        }
        private static GeocodeDocument getGeocodeDocument(){
            GeocodeDocument  geocodeDocument = GeocodeDocument.Factory.newInstance();
            geocodeDocument.setGeocode(Geocode.Factory.newInstance());
            geocodeDocument.getGeocode().setRequest(GeocodeRequest.Factory.newInstance());
            geocodeDocument.getGeocode().getRequest().setQuery("1 Microsoft Way, Redmond, WA");
            geocodeDocument.getGeocode().getRequest().setCredentials(getCredentials());
            return geocodeDocument;
        }

     

    Can you please help me where I am goining wrong while creating request.

     

    Thanks

    Anu

     

    Sunday, May 15, 2011 12:52 AM
  • The instructions were for using the Axis package, not Axis2.

    In any case, if there is no specific need to use Axis, don't use it. Use the new REST service instead.

    Check out a geocoding sample at http://ngjon.wordpress.com/2011/05/20/bing-maps-geocoding-rest-service-java-ized/. You'll save a lot of hair.

    Saturday, May 21, 2011 1:53 AM
  • I am using imagery soap service and getting the Map image given the 2 points. But it does not highlight the route. which property should be populated in the request to highlight the route.

    Following is the request:

    private static GetMapUri createMapUriRequest(){
            net.virtualearth.dev.webservices.v1.imagery.contracts.ObjectFactory objFactory = new net.virtualearth.dev.webservices.v1.imagery.contracts.ObjectFactory();
            GetMapUri mapUriRequest = objFactory.createGetMapUri();
            MapUriRequest request = new MapUriRequest();
            mapUriRequest.setRequest(request);
            mapUriRequest.getRequest().setCredentials(populateCredentials());
            mapUriRequest.getRequest().setPushpins(populatePushpins());
            mapUriRequest.getRequest().setOptions(populateMapUriOptions());
            return mapUriRequest;
           
        }

     

     

     



    Thursday, June 9, 2011 9:00 PM
  • The SOAP imagery service has limited features. The last I checked it did not support polylines or polygons so drawing routes required a lot of extra work. Look at using the REST services. They are a lot easier to use and have a lot more features. http://msdn.microsoft.com/en-us/library/ff701724.aspx
    Windows Live Developer MVP - http://rbrundritt.wordpress.com | http://inknowledge.co.uk
    Friday, June 10, 2011 9:39 AM
  • Thankyou..
    Anuradha daga
    Tuesday, June 14, 2011 6:17 PM