1 package test.functional; 2 3 import javax.xml.messaging.URLEndpoint; 4 import javax.xml.soap.MessageFactory ; 5 import javax.xml.soap.SOAPConnection ; 6 import javax.xml.soap.SOAPConnectionFactory ; 7 import javax.xml.soap.SOAPMessage ; 8 9 import junit.framework.TestCase; 10 11 14 public class TestMimeHeaders extends TestCase { 15 16 public TestMimeHeaders(String s) { 17 super(s); 18 } 19 20 public void testTransferMimeHeadersToHttpHeaders() throws Exception { 21 SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance(); 22 SOAPConnection con = scFactory.createConnection(); 23 24 MessageFactory factory = MessageFactory.newInstance(); 25 SOAPMessage message = factory.createMessage(); 26 String headerName = "foo"; 27 String headerValue = "bar"; 28 message.getMimeHeaders().addHeader(headerName, headerValue); 29 30 URLEndpoint endpoint = new URLEndpoint("http://localhost:8080/axis/services/TestMimeHeaderService"); 31 SOAPMessage response = con.call(message, endpoint); 32 String [] responseHeader = response.getMimeHeaders().getHeader(headerName); 33 assertTrue("Response header was null", responseHeader != null); 34 assertEquals("ResponseHeader.length wasn't 1", 1, responseHeader.length); 35 assertEquals("Header value didn't match", headerValue, responseHeader[0]); 36 } 37 } 38 | Popular Tags |