Publishing UDDI Data

UDDI publishing requests must be sent via an SSL connection and are restricted to authorized users only. To specify an HTTPS URL, use the setPublishURL( ) method. To obtain user authorization, you must use the proxy get_authToken( ) method. This method requires a username and password and returns an authentication token, which must be passed to all subsequent publishing methods.

Our final example illustrates how to save a new businessEntity record, and also illustrates the generic technique for obtaining a user authentication token. The code creates a new businessEntity record for Acme Parts, then confirms that the record was published by extracting and displaying the new businessKey.

The program expects two command-line arguments, in which you can specify a username and password. For example, the following command line:

java com.ecerami.uddi.saveBusiness ethan@ecerami.com oreilly

generates the following output:

Saving New Business:  Acme Parts
Authentication Token:1IbuzUmG2DuPzkcoUd1I6iy*BqWwxPhuFWf2!ggowk*6Kiznlu4sjQeJT
OnuL2c1Smm8m28aogU!I6ZL73yROf3Q$$;1IbuzUmG2AoqvPmRavvTeO1UsaVLQk0AmGYVyyxwk3
    2Kb4
c3jMROMo4Rlp7kaQYRCXu9!95wQ8FZTIjE!47uKC9NPCCryf0Yh!IltwfYMCaPKTq*R0rTWMrzcg
    UWEt
!g859iKxlE*w7QPIx8n8aYWs8WCkAn7UHwyb
Published Business Key:  3deafa60-0023-4220-b3e0-0c87cb34526a

Example 9-3 includes a UDDIUtil class that is responsible for authenticating users. Note that the class specifies an SSL provider:

System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); ...

Get Web Services Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.