package org.jboss.test.webservice.jbws64;
import junit.framework.Test;
import org.jboss.test.JBossTestCase;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPMessage;
import java.io.ByteArrayInputStream;
public class JBWS64TestCase extends JBossTestCase
{
public JBWS64TestCase(String name)
{
super(name);
}
public static Test suite() throws Exception
{
return getDeploySetup(JBWS64TestCase.class, "ws4ee-jbws64.war");
}
public void testEndpoint() throws Exception
{
String reqMsgStr =
"<soapenv:Envelope" +
" xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'" +
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
" <soapenv:Body>" +
" <publish xmlns='http://webservices.est.useme.etish.com'>" +
" <in0 xmlns=''>joel</in0>" +
" <in1 xmlns=''>secret</in1>" +
" <in2 xmlns=''>1</in2>" +
" <in3 xmlns=''>6</in3>" +
" <in4 xmlns=''>2</in4>" +
" </publish>" +
" </soapenv:Body>" +
"</soapenv:Envelope>";
MessageFactory msgFactory = MessageFactory.newInstance();
SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(reqMsgStr.getBytes()));
SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance();
SOAPConnection con = factory.createConnection();
SOAPMessage resMsg = con.call(reqMsg, "http://" + getServerHost() + ":8080/ws4ee-jbws64");
SOAPBody soapBody = resMsg.getSOAPBody();
SOAPElement soapBodyElement = (SOAPElement)soapBody.getChildElements().next();
SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
assertEquals("joel,secret,1,6,2", soapElement.getValue());
}
}