01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.jaxws;
19:
20: import java.util.List;
21:
22: import javax.xml.namespace.QName;
23:
24: import org.w3c.dom.Node;
25:
26: import org.apache.cxf.Bus;
27: import org.apache.cxf.frontend.ServerFactoryBean;
28: import org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration;
29: import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
30: import org.apache.cxf.service.Service;
31: import org.apache.cxf.service.model.MessagePartInfo;
32: import org.apache.cxf.service.model.OperationInfo;
33: import org.apache.cxf.transport.local.LocalTransportFactory;
34: import org.apache.header_test.TestHeaderImpl;
35: import org.apache.header_test.types.TestHeader5;
36: import org.apache.header_test.types.TestHeader5ResponseBody;
37: import org.junit.Test;
38:
39: public class HeaderTest extends AbstractJaxWsTest {
40:
41: @Test
42: public void testInvocation() throws Exception {
43: JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
44:
45: Bus bus = getBus();
46: bean.setBus(bus);
47: bean.setServiceClass(TestHeaderImpl.class);
48:
49: Service service = bean.create();
50:
51: OperationInfo op = service.getServiceInfos().get(0)
52: .getInterface().getOperation(
53: new QName(service.getName().getNamespaceURI(),
54: "testHeader5"));
55: assertNotNull(op);
56: List<MessagePartInfo> parts = op.getInput().getMessageParts();
57: assertEquals(1, parts.size());
58:
59: MessagePartInfo part = parts.get(0);
60: assertNotNull(part.getTypeClass());
61: assertEquals(TestHeader5.class, part.getTypeClass());
62:
63: parts = op.getOutput().getMessageParts();
64: assertEquals(2, parts.size());
65:
66: part = parts.get(1);
67: assertNotNull(part.getTypeClass());
68: assertEquals(TestHeader5ResponseBody.class, part.getTypeClass());
69:
70: part = parts.get(0);
71: assertNotNull(part.getTypeClass());
72: assertEquals(TestHeader5.class, part.getTypeClass());
73:
74: // part = parts.get(1);
75: // assertNotNull(part.getTypeClass());
76:
77: ServerFactoryBean svr = new ServerFactoryBean();
78: svr.setBus(bus);
79: svr.setServiceFactory(bean);
80: svr.setServiceBean(new TestHeaderImpl());
81: svr
82: .setAddress("http://localhost:9104/SoapHeaderContext/SoapHeaderPort");
83: svr.setBindingConfig(new JaxWsSoapBindingConfiguration(bean));
84:
85: svr.create();
86:
87: Node response = invoke(
88: "http://localhost:9104/SoapHeaderContext/SoapHeaderPort",
89: LocalTransportFactory.TRANSPORT_ID, "testHeader5.xml");
90:
91: assertNotNull(response);
92: assertNoFault(response);
93:
94: addNamespace("t", "http://apache.org/header_test/types");
95: assertValid("//s:Header/t:testHeader5", response);
96: }
97: }
|