Package org.jboss.soa.bpel.tests.harness

Source Code of org.jboss.soa.bpel.tests.harness.SecureServiceTestHarnessImpl

/**
* Please modify this class to meet your needs
* This class is not complete
*/

package org.jboss.soa.bpel.tests.harness;

import java.util.logging.Logger;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;

import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor;
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;

/**
* This class was generated by Apache CXF 2.2.6
* Mon Jun 14 11:12:40 BST 2010
* Generated source version: 2.2.6
*
*/

@javax.jws.WebService(
                      serviceName = "SecureServiceTestHarnessService",
                      portName = "SecureServiceTestHarnessPort",
                      targetNamespace = "http://harness.tests.bpel.soa.jboss.org/",
                      endpointInterface = "org.jboss.soa.bpel.tests.harness.SecureServiceTestHarness")
                     
public class SecureServiceTestHarnessImpl implements SecureServiceTestHarness {

    private static final QName SERVICE_NAME = new QName("http://www.jboss.org/bpel/examples/wsdl", "SecureHelloService");

    private static final Logger LOG = Logger.getLogger(SecureServiceTestHarnessImpl.class.getName());

    /* (non-Javadoc)
     * @see org.jboss.soa.bpel.tests.harness.SecureServiceTestHarness#runTest(int  arg0 )*
     */
    public boolean runTest(int arg0) {
      LOG.info("Executing operation runTest("+arg0+")");

      try {
        SpringBusFactory bf = new SpringBusFactory();
        URL busFile = SecureServiceTestHarnessImpl.class.getResource("/wssec.xml");

        Bus bus = bf.createBus(busFile.toString());
        bf.setThreadDefaultBus(bus);

        QName portName=new QName("http://www.jboss.org/bpel/examples/wsdl", "SecureHelloPort");
       
        URL wsdlURL = new URL("http://127.0.0.1:8080/Quickstart_bpel_secure_serviceWS?wsdl");
       
        Service service = Service.create(wsdlURL, SERVICE_NAME);
        Dispatch<SOAPMessage> dispatcher = service.createDispatch(
            portName, SOAPMessage.class, Service.Mode.MESSAGE);
      
        MessageFactory factory = MessageFactory.newInstance();
       
        String str="<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:wsdl=\"http://www.jboss.org/bpel/examples/wsdl\">"+
          "<soapenv:Header/><soapenv:Body><wsdl:hello><TestPart>Hello</TestPart></wsdl:hello></soapenv:Body></soapenv:Envelope>";

        java.io.InputStream is=new java.io.ByteArrayInputStream(str.getBytes());
       
        SOAPMessage soapReq1 = factory.createMessage(null, is);
       
        System.out.println("Invoking server through Dispatch interface using SOAPMessage");
        SOAPMessage soapResp = dispatcher.invoke(soapReq1);
       
        String result=soapResp.getSOAPBody().getTextContent();
       
        System.out.println("Response from server: " + result);

            return result.contains("Hello World");
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }
    }

}
TOP

Related Classes of org.jboss.soa.bpel.tests.harness.SecureServiceTestHarnessImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.