what is printed to the browser?
On Mon, Apr 15, 2013 at 11:05 PM, Edgar Orduña <[email protected]> wrote: > i have the jars and i dont have idea what happen, this is the code of my > example and when i run my example only the source code from "catch" runs. > > Thanks > > import java.io.IOException; > import java.io.PrintWriter; > import javax.servlet.ServletException; > import javax.servlet.http.HttpServlet; > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpServletResponse; > import org.uddi.api_v3.*; > import org.apache.juddi.ClassUtil; > import org.apache.juddi.api_v3.*; > import org.apache.juddi.v3.client.config.UDDIClientContainer; > import org.apache.juddi.v3.client.i18n.EntityForLang; > import org.apache.juddi.v3.client.transport.Transport; > import org.uddi.v3_service.UDDISecurityPortType; > import org.uddi.v3_service.UDDIPublicationPortType; > import org.apache.juddi.v3_service.JUDDIApiPortType; > > > public class ServletPublish extends HttpServlet { > > private static UDDISecurityPortType security = null; > private static JUDDIApiPortType juddiApi = null; > private static UDDIPublicationPortType publish = null; > String Name; > > public ServletPublish() { > try { > String clazz = UDDIClientContainer.getUDDIClerkManager(null). > getClientConfig().getUDDINode("default").getProxyTransport(); > Class<?> transportClass = ClassUtil.forName(clazz, > Transport.class); > if (transportClass!=null) { > Transport transport = (Transport) transportClass. > getConstructor(String.class).newInstance("default"); > > security = transport.getUDDISecurityService(); > juddiApi = transport.getJUDDIApiService(); > publish = transport.getUDDIPublishService(); > } > } catch (Exception e) { > > e.printStackTrace(); > } > } > > @Override > protected void doGet(HttpServletRequest request, HttpServletResponse > response) throws ServletException, IOException > { > > Name = request.getParameter("nombre"); > ServletPublish sp = new ServletPublish(); > sp.publish(Name, response); > > > } > > @Override > protected void doPost(HttpServletRequest request, HttpServletResponse > response) throws ServletException, IOException > { > // TODO Auto-generated method stub > doGet(request,response); > > > } > > public void publish(String nom, HttpServletResponse response)throws > ServletException, IOException { > response.setContentType("text/html;charset=UTF-8"); > PrintWriter out = response.getWriter(); > > try{ > // Setting up the values to get an authentication token for the > 'root' user ('root' user has admin privileges > // and can save other publishers). > > GetAuthToken getAuthTokenRoot = new GetAuthToken(); > getAuthTokenRoot.setUserID("root"); > getAuthTokenRoot.setCred("root"); > > // Making API call that retrieves the authentication token > for the 'root' user. > AuthToken rootAuthToken = > security.getAuthToken(getAuthTokenRoot); > //System.out.println ("root AUTHTOKEN = " + > rootAuthToken.getAuthInfo()); > > // Creating a new publisher that we will use to publish our > entities to. > Publisher p = new Publisher(); > p.setAuthorizedName("my-publisher"); > p.setPublisherName("My Publisher"); > > // Adding the publisher to the "save" structure, using the > 'root' user authentication info and saving away. > SavePublisher sp = new SavePublisher(); > sp.getPublisher().add(p); > sp.setAuthInfo(rootAuthToken.getAuthInfo()); > juddiApi.savePublisher(sp); > > // Our publisher is now saved, so now we want to retrieve > its authentication token > GetAuthToken getAuthTokenMyPub = new GetAuthToken(); > getAuthTokenMyPub.setUserID("my-publisher"); > getAuthTokenMyPub.setCred("root"); > AuthToken myPubAuthToken = > security.getAuthToken(getAuthTokenMyPub); > //System.out.println ("myPub AUTHTOKEN = " + > myPubAuthToken.getAuthInfo()); > > // Creating the parent business entity that will contain our > service. > BusinessEntity myBusEntity = new BusinessEntity(); > Name myBusName = new Name(); > myBusName.setValue(nom); > myBusEntity.getName().add(myBusName); > > // Adding the business entity to the "save" structure, using > our publisher's authentication info and saving away. > SaveBusiness sb = new SaveBusiness(); > sb.getBusinessEntity().add(myBusEntity); > sb.setAuthInfo(myPubAuthToken.getAuthInfo()); > BusinessDetail bd = publish.saveBusiness(sb); > String myBusKey = > bd.getBusinessEntity().get(0).getBusinessKey(); > > out.println("<div id='cuerpo2'>);" > +"<table>"); > out.println("<tr>" > + "<td><b>root AUTHTOKEN:</b> " + > rootAuthToken.getAuthInfo() + "</td></tr>"); > out.println("<tr><td><b>myPub AUTHTOKEN: </b>" + > myPubAuthToken.getAuthInfo() + "</td></tr>"); > out.println("<tr>" > + "<td><b>Name:</b> " + nom + "</td></tr>"); > out.println("<tr><td><b>BusinessKey: </b>" + myBusKey + > "</td></tr>" > + "</table>" > +"</div>"); > > } > catch (Exception e) { > > out.println("<div id=\"cuerpo2\">" > +"error" > +"<br>"+ nom +"" > +"</div>"); > > > e.printStackTrace(); > } > } > > } > > > 2013/4/15 Alex O'Ree <[email protected]> >> >> No idea what the root cause is, but it sounds like the code you're >> stepping though, when compiled, does not match what is in the servlet >> container. Try to delete all temp/work folders and clean, build and >> redeploy. There's no reason why it wouldn't work as a servlet, so long >> as you have all the required jar's within the classpath >> >> On Mon, Apr 15, 2013 at 4:58 PM, Edgar Orduña <[email protected]> wrote: >> > Hi >> > I have a question, can i use the SimplePublish.java example like a >> > Servlet >> > from Java? >> > or the example runs only on console. >> > >> > I'm Trying to use the SimplePublish.java like a servlet but in the >> > example >> > the source code from "try" doesn't run only the source code from "catch" >> > runs. >> > >> > Thanks > >
