FishEye 1.6 : Writing SOAP Clients for Fisheye or Crucible RPC Plugins
This page last changed on Sep 22, 2008 by edawson.
This is an example of a SOAP client calling a Fisheye/Crucible SOAP RPC plugin It uses the JAX-WS dispatch approach to calling SOAP, rather than generating stubs from the WSDL. URL wsdlURL = new URL("http://localhost:6060/foo/service/review?wsdl"); String namespace = "http://rpc.spi.crucible.atlassian.com/"; Service service = Service.create(wsdlURL, new QName(namespace, "Review")); Dispatch<SOAPMessage> disp = service.createDispatch(new QName(namespace, "ReviewPort"), SOAPMessage.class, Service.Mode.MESSAGE); MessageFactory mf = MessageFactory.newInstance(); SOAPMessage call = mf.createMessage(); SOAPBody body = call.getSOAPBody(); QName bodyName = new QName(namespace, "getAllReviews", "m"); SOAPBodyElement bodyElement = body.addBodyElement(bodyName); QName name = new QName("token"); SOAPElement symbol = bodyElement.addChildElement(name); symbol.addTextNode("blank"); // we are not providing a valid token as we are using Trusted Application Authentication /** this section is for Trusted Application Authentication **/ EncryptedCertificate cert = currentApplication.encode("matt"); Map<String, List> headers = new HashMap<String,List>(); headers.put(CurrentApplication.HEADER_TRUSTED_APP_ID, Collections.singletonList(cert.getID())); headers.put(CurrentApplication.HEADER_TRUSTED_APP_CERT, Collections.singletonList(cert.getCertificate())); headers.put(CurrentApplication.HEADER_TRUSTED_APP_SECRET_KEY, Collections.singletonList(cert.getSecretKey())); disp.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, headers); /** end Trusted Application Authentication setup **/ SOAPMessage response = disp.invoke(call); response.writeTo(System.out); Note that the example above is using Trusted Application Authentication. If you were using username/password authentication you would first call the login method on the http://localhost:6060/foo/service/auth endpoint, and pass the token it returned instead of the string "blank". |
![]() |
Document generated by Confluence on Sep 23, 2008 01:42 |