示例#1
0
  protected void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    // Create the port
    //    URL wsdlURL = getServletContext().getResource("/WEB-INF/wsdl/TestService.wsdl");
    URL wsdlURL = new URL("http://" + hostName + ":8081/jaxws-endpoint?wsdl");
    QName qname = new QName("http://org.jboss.ws/jaxws/endpoint", "EndpointService");
    Service service = Service.create(wsdlURL, qname);
    EndpointInterface port = (EndpointInterface) service.getPort(EndpointInterface.class);

    // Invoke the endpoint
    String param = req.getParameter("param");
    String retStr = port.echo(param);

    // Test epr
    DocumentBuilder builder = getDocumentBuilder();
    assertEndpointReference(
        endpoint1.getEndpointReference(DOMUtils.parse(TEST_ELEMENT, builder)),
        TEST_ELEMENT,
        builder);
    assertEndpointReference(
        endpoint1.getEndpointReference(W3CEndpointReference.class, (Element[]) null),
        null,
        builder);

    // Return the result
    PrintWriter pw = new PrintWriter(res.getWriter());
    pw.print(retStr);
    pw.close();
  }
示例#2
0
 private void assertEndpointReference(
     EndpointReference epr, String refPar, DocumentBuilder builder) throws IOException {
   Logger.getLogger(this.getClass()).info("epr: " + epr);
   assert (W3CEndpointReference.class.getName().equals(epr.getClass().getName()));
   Element endpointReference = DOMUtils.parse(epr.toString(), builder);
   assert ("EndpointReference".equals(endpointReference.getNodeName()));
   assert ("http://www.w3.org/2005/08/addressing".equals(endpointReference.getAttribute("xmlns")));
   NodeList addresses = endpointReference.getElementsByTagName("Address");
   assert (addresses.getLength() == 1);
   assert (("http://" + hostName + ":8081/jaxws-endpoint")
       .equals(addresses.item(0).getFirstChild().getNodeValue()));
   if (refPar != null) {
     Element refEle = DOMUtils.parse(refPar, builder);
     NodeList nodeList =
         endpointReference.getElementsByTagNameNS(refEle.getNamespaceURI(), refEle.getLocalName());
     assert (nodeList.getLength() == 1);
     assert (refEle.getTextContent().equals(nodeList.item(0).getTextContent()));
   }
 }