3 Replies Latest reply on Mar 23, 2016 10:25 AM by simplex-software

    How to test a SOAP binding

    simplex-software

      Greetings,

       

      In a composite, I have a service exposing a WSDL interface and having a SOAP binding. The service has a reference to a component with a JPA binding. In order to test the composite, I deploy it and I use SoapUI. But I'm wondering how to test it using the Switchyard test kit or Arquillian ?

      Using the Switchyard test kit, as follows:

       

      @RunWith(SwitchYardRunner.class)

      @SwitchYardTestCaseConfig(config = SwitchYardTestCaseConfig.SWITCHYARD_XML, mixins = { CDIMixIn.class })

      public class PaymentTest {

        @ServiceOperation("Payment")

        private Invoker service;

       

        @Test

        public void testMakePayment() throws Exception {

          Invoice invoice = new Invoice("companyName", new Integer(160), new BigDecimal(75), new Integer(35));

          service.operation("makePayment").sendInOnly(invoice);

        }

      }

      raises javax.persistence.PersistenceException: No Persistence provider for EntityManager. This must be obviously because the Switchyard test kit uses jetty who, as opposed to EAP/WildFly, doesn't provide any EntityManager instance. It should be created using an EntityManager factory, like in non Java EE applications.

      Trying to test with Arquillian, as follows:

       

      @RunWith(Arquillian.class)

      public class ArquillianPaymentTest1 {

       

        @Deployment

        public static JavaArchive createDeployment() {

          return ShrinkWrap.createFromZipFile(JavaArchive.class, new File("target/switchyard-demo-0.0.1-SNAPSHOT.jar"));

        }

       

        @Test

        public void test() throws MalformedURLException {

          Service service = Service.create(new URL ("http://localhost:8080/pay/Payment?wsdl"), new QName("...", "Payment"));

          Invoice invoice = new Invoice("companyName", new Integer(160), new BigDecimal(75), new Integer(35));

          service.getPort(Payment.class).makePayment(invoice);

        }

      }

      correctly starts the EAP managed container, deploys the composite as shown below:

       

      19:31:40,549 INFO  [org.jboss.ws.cxf.metadata] (MSC service thread 1-1) JBWS024061: Adding service endpoint metadata: id=Payment

      address=http://localhost:8080/pay/Payment

      implementor=org.switchyard.component.soap.endpoint.BaseWebService

      serviceName={urn:fr.simplex-software.example.switchyard:switchyard-demo:1.0}Payment

      portName={urn:fr.simplex-software.example.switchyard:switchyard-demo:1.0}PaymentPort

      annotationWsdlLocation=null

      wsdlLocationOverride=vfs:/C:/Users/nicolas/workspace8/switchyard-demo/content/switchyard-demo-0.0.1-SNAPSHOT.jar/Payment.wsdl

      mtomEnabled=false


      but raises the following exception:


      19:31:42,752 SEVERE [org.jboss.arquillian.protocol.jmx.JMXTestRunner] (pool-1-thread-1) Failed: ... ArquillianPaymentTest.test: javax.xml.ws.WebServiceException: Service endpoint interface class ... Payment does not have a javax.jws.WebService annotation.


      which is, of course, true.


      So, is there anyway I could test in container this service, using either Switchyard test kit, or Arquillian, or a combination of both ?


      Many thanks in advance,


      Nicolas

        • 1. Re: How to test a SOAP binding
          igarashitm
          • 2. Re: How to test a SOAP binding
            simplex-software

            Yes, I know I can use HttpMixIn. But this is not at all handy as HttpMixIn doesn't know anything about SOAP and one has to provide a static SOAP payload to invoke a web service and to perform character strings comparations on another static SOAP response in order to check the result.

            My point was to test a web service using a JAX-WS client and not a blind HTTP client which, of course, could always be used.

            Soap-UI is, in this case, much more handy as, at least, it generates the SOAP payload based on the WSDL.

            So how is one supposed to test with HttpMixIn ? To generate with Soap-UI the SOAP request and response, to save them in files and to use these files with HttpMixIn ? I don't think it makes much sense.

            It must be a way to test web services in Switchyard using JAX-WS clients.

            • 3. Re: How to test a SOAP binding
              simplex-software

              Hello,

               

              I solved my problem by generating a JAX-WS proxy client, out of my Switchyard service, using the CXF wsdl2java command. In effect, I used the org.apache.cxf:cxf-codegen-plugin maven plugin. Then, I wrote an Arquillian unit test which calls the Switchyard service, using the generated proxy JAX-WS client. THis works as expected. But, for some reason, the similar unit test which uses the Switchyard test kit and CdiMixIn doesn't work.

               

              Kind regards,

               

              Nicolas