dev@ws-test-harness.java.net

Problem in bsh in test harness

From: Bhakti Mehta <Bhakti.Mehta_at_Sun.COM>
Date: Thu, 12 Oct 2006 10:50:01 -0700

Hi,
I am attaching the following bsh. This works with yesterday's harness
bits and produces this error with the latest harness
http://kohsuke.sfbay/hudson/job/wsit-e2e-test-local/131/testReport/wsrm.dispatch/client%20test_bsh/wsrm_dispatch_client_test_bsh/

Sourced file: test.bsh unknown error: null : at Line: 96 : in file: test.bsh : testSendEcho ( )

Called from method: testSendEcho : at Line: 96 : in file: test.bsh : testSendEcho ( )
        at bsh.Interpreter.eval(Interpreter.java:699)
        at com.sun.xml.ws.test.client.InterpreterEx.eval(InterpreterEx.java:50)
        at com.sun.xml.ws.test.exec.ClientExecutor.runBare(ClientExecutor.java:60)
        at com.sun.xml.ws.test.Main$1.doRun(Main.java:227)
        at com.sun.xml.ws.test.Main.run(Main.java:235)
        at com.sun.xml.ws.test.Main.doMain(Main.java:165)
        at com.sun.xml.ws.test.Main.main(Main.java:153)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)


Is this a bug with the latest bsh integated in harness?
Regards,
Bhakti



import javax.xml.ws.BindingProvider;
import com.sun.xml.ws.rm.jaxws.runtime.client.ClientSession;
import com.sun.xml.ws.rm.RMException;

import javax.xml.bind.*;
import javax.xml.namespace.*;
import javax.xml.ws.WebServiceRef;
import javax.xml.ws.Dispatch;
import javax.xml.ws.soap.SOAPBinding;

import javax.xml.soap.SOAPMessage;
import javax.xml.soap.MessageFactory;

import java.io.ByteArrayOutputStream;
import java.io.StringReader;

import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.Source;

import javax.xml.namespace.QName;


import junit.framework.TestCase;

 helloRequest = "<?xml version=\"1.0\" ?>" +
            "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
            " <S:Header></S:Header>" +
            " <S:Body>" +
            " <echoString xmlns=\"http://tempuri.org/\">" +
            " <Text>Hello There! no0</Text>" +
            " <Sequence>seq! no0</Sequence>" +
            " </echoString>" +
            " </S:Body>" +
            "</S:Envelope>";

       static PingService service = new PingService();

        
        private final String NAMESPACEURI = "http://tempuri.org/";
        private static final String SERVICE_NAME = "PingService";
        private static final String PORT_NAME = "WSHttpBinding_IPing";
        private QName SERVICE_QNAME = new QName(NAMESPACEURI, SERVICE_NAME);
        private QName PORT_QNAME = new QName(NAMESPACEURI, PORT_NAME);



     public void testSendEcho() {
        System.out.println("doInvoke");
        // Dispatch<SOAPMessage> dispatchMsg = null;
        try {
            dispatchMsg = service.createDispatch(PORT_QNAME, SOAPMessage.class, javax.xml.ws.Service.Mode.MESSAGE,new WebServiceFeature[] {new javax.xml.ws.RespectBindingFeature()});
            SOAPMessage reqMsg = makeSOAPMessage(helloRequest);
            System.out.println("SOAPMessage request: " + getSOAPMessageAsString(reqMsg));
            SOAPMessage resMsg = dispatchMsg.invoke(reqMsg);
            System.out.println("SOAPPMessage response: " + getSOAPMessageAsString(resMsg));
            String responseMessage = getSOAPMessageAsString(resMsg);
            if (!responseMessage.contains(new String("Action"))){
               fail("The response Message is not as expected");
            }

        } catch (Exception e) {
            e.printStackTrace();
           fail("The response Message is not as expected");
        }
    }

    private String getSOAPMessageAsString(SOAPMessage msg)
    {
        ByteArrayOutputStream baos = null;
        String s = null;
        try {
            baos = new ByteArrayOutputStream();
            msg.writeTo(baos);
            s = baos.toString();
        } catch(Exception e) {
            e.printStackTrace();
        }
        return s;
    }

    private SOAPMessage makeSOAPMessage(String msg)
    {
        try {
            MessageFactory factory = MessageFactory.newInstance();
            SOAPMessage message = factory.createMessage();
            message.getSOAPPart().setContent((Source) new StreamSource(new StringReader(msg)));
            message.saveChanges();
            return message;
        }
        catch (Exception e) {
            return null;
        }
    }


testSendEcho();