Archive for the 'WebServices' Category

 

Basic REST web service example ..

May 08, 2015 in Java, REST, Web, WebServices

From: http://getj2ee.over-blog.com/article-tutorial-rest-with-spring-mvc-and-maven-97283997.html

[java]

@Controller // –> Declare a Spring MVC Controller

@RequestMapping(“/computer”) // –> Map an URI with a controller or a method

@PathVariable // –> Read a variable in an Uri and assign this value to a java variable

@RequestBody // –> Declare a Pojo class to map the http request body

@ResponseBody // –> Declare a Pojo class to generate Json content to return to the http client

// Declaration as this class as a controller
@Controller

// Declaration that this controller handles requests on uri */computer
@RequestMapping(“/computer”)

public class ComputerController {

// Stores computers
private static final ComputerStorage computerStorage = new ComputerStorage();

// Declare a method that handle all GET request on */computer
@RequestMapping(method = RequestMethod.GET)

// Return a list of computer to the http client
@ResponseBody public List getComputers() {
return computerStorage.getAll();
}
}

[/java]

Geolocation webservices notes

Oct 11, 2011 in Geolocation, WebServices

Zip code to geolocation service (zip to geolocation, postal code to geolocation)

http://www.webservicemart.com/uszip.asmx/ValidateZip?zipcode=95014

Bing geolocation query example

From: http://msdn.microsoft.com/en-us/library/ff701714.aspx

http://dev.virtualearth.net/REST/v1/Locations?CountryRegion=US&adminDistrict=WA&locality=Somewhere&postalCode=98001&addressLine=100%20Main%20St.&key=BingMapsKey

Or using a python script to exercise and experiment :


import os

# python qbing1.py

BKEY = 'BlahBlahMyBingKeyBluhBluh.'

def makeurl1():
    burl = 'http://dev.virtualearth.net/REST/v1/Locations'
    burl += '?CountryRegion=US'
    burl += '\&adminDistrict=WA'
    burl += '\&locality=Somewhere'
    burl += '\&postalCode=98001'
    burl += '\&addressLine=100%20Main%20St.'
    burl += '\&key=' + BKEY

    return burl;

def makeurl2():
    burl = 'http://dev.virtualearth.net/REST/v1/Locations'
    burl += '?CountryRegion=US'
    burl += '\&locality=San%20Francisco'
    burl += '\&postalCode=94121'
    burl += '\&addressLine=529%2029th%20Ave.'
    burl += '\&key=' + BKEY

    return burl;

burl = makeurl2()

print 'URL: ' + burl

sts = os.system("wget -O qbing1.json " + burl )

Yahoo (webservices) query language

http://developer.yahoo.com/yql/console/

Notes on “Java Web Services” ..

Jul 02, 2009 in Books, Java, Software, WebServices

This book is a bit old.. 2002..




  • — SOA – Service Oriented Architecture
    — 3 major roles: Provider, Registry (Broker) and Requester.
    — SOA is based on web services.
  • — SOAP – Simple Object Access Protocol
    — 2 major methods: Message-based Document Exchange AND RPC
    (Remote Procedure Calls).
    — All structures based on XML.
    — A SOAP message contains an Envelope and a Header.
    — A SOAP message may contain (MIME) attachments.
    — Main transport protocol is HTTP(S).
    — Providers (Receivers) are usually based on Servlets.
  • — SOAP-RPC
    — Method signatures contain a single SOAP structure.
    — SOAP service methods must match info in deployment descriptor.
    — Errors and Faults: VersionMismatch, MustUnderstand, DTDNotSupported, etc..
  • — WSDL – Web Services Description Language
    — WSDL is an XML grammar for describing a web service
    as a collection of access end-points capable of exchanging
    messages in a procedure- or document-oriented fashion (p. 72)
    — The reasonable flow is to create service methods and
    than generate WSDL from code using tools.
    — Best practices: web service is (functionally) coarse-grained
    and messages are more business-oriented than programmatic.
  • — UDDI – Universal Description, Discovery and Integration
    — Similar to an Internet search engine for businesses.
    — UBR – UDDI Business Registry (the Public Cloud).
    — Designed for B2B mostly.
    — 2 APIs: inquiry and publishing API.
    — JAXR = Java API for XML Registries.
    — Some details: Categorization (NAICS, ISO, etc..),
    Identifier (DUNS, Thomas Reg, etc),
    tModel (web service metadata)
  • — JAX-RPC and JAXM
    — JAXM = Java API for XML Messaging.
    — JAX-RPC = Java API for XML-based RPC.
    — JAXM may be used as a frontend to SOAP-based messaging
    frameworks through the use of “profiles”.
    — JAX-RPC covers code generation for client and server parts,
    dynamic SOAP, creating services within J2EE and J2SE environments,
    bindings, serialization, mapping of datatypes between WSDL and Java,
    etc..
  • — The Java Web Service (JWS) Standard
    — Proposed by BEA, using templates to create simple web services.
    — Example (HelloWorld.jws <- note the .jws extension)
    Note the annotations @operation, @conversation ..

    import com.bea.jws.*
    
    public class HelloWorld extends Service {
      /**
      * @operation
      * @conversation stateless
      */
      public String getHelloWorld() {
        return "Hello, World!";
      }
    }
    

    Other values for @conversation are ‘start’, ‘continue’ or
    ‘finish’. The ‘start’ directive, for example, starts a session.

  • — Security notes
    — Use of SSL (HTTPS), encryption, signing and secure hashing.
    — Security Assertion Markup Language (SAML) – used with Single Sign-On (SSO).
  • — Resources
    http://aws.amazon.com/
    http://seekda.com/
    http://www.programmableweb.com/
    http://www.webservices.org/
    http://xmethods.com/

Colophon – European (Alpine) Ibex – a wild goat.