use of org.apache.cxf.wsdl.http.AddressType in project cxf by apache.
the class HttpAddressPlugin method createExtension.
public ExtensibilityElement createExtension(final Map<String, Object> args) throws WSDLException {
String address = getOption(args, ToolConstants.CFG_ADDRESS);
ExtensibilityElement addr = registry.createExtension(Port.class, WSDLConstants.QNAME_XMLHTTP_BINDING_ADDRESS);
if (addr instanceof AddressType) {
((AddressType) addr).setLocation(address);
}
if (addr instanceof HTTPAddress) {
((HTTPAddress) addr).setLocationURI(address);
}
return addr;
}
use of org.apache.cxf.wsdl.http.AddressType in project cxf by apache.
the class ServiceImpl method initializePorts.
private void initializePorts() {
try {
Definition def = bus.getExtension(WSDLManager.class).getDefinition(wsdlURL);
javax.wsdl.Service serv = def.getService(serviceName);
if (serv == null) {
throw new WebServiceException("Could not find service named " + serviceName + " in wsdl " + wsdlURL);
}
Map<String, Port> wsdlports = CastUtils.cast(serv.getPorts());
for (Port port : wsdlports.values()) {
QName name = new QName(serviceName.getNamespaceURI(), port.getName());
String address = null;
String bindingID = null;
List<? extends ExtensibilityElement> extensions = CastUtils.cast(port.getBinding().getExtensibilityElements());
if (!extensions.isEmpty()) {
ExtensibilityElement e = extensions.get(0);
if (e instanceof SoapBinding) {
bindingID = SOAPBinding.SOAP11HTTP_BINDING;
} else if (e instanceof SOAP12Binding) {
bindingID = SOAPBinding.SOAP12HTTP_BINDING;
} else if (e instanceof javax.wsdl.extensions.soap.SOAPBinding) {
bindingID = SOAPBinding.SOAP11HTTP_BINDING;
}
}
extensions = CastUtils.cast(port.getExtensibilityElements());
if (!extensions.isEmpty()) {
ExtensibilityElement e = extensions.get(0);
if (e instanceof SoapAddress) {
address = ((SoapAddress) e).getLocationURI();
} else if (e instanceof AddressType) {
address = ((AddressType) e).getLocation();
} else if (e instanceof SOAP12Address) {
address = ((SOAP12Address) e).getLocationURI();
} else if (e instanceof SOAPAddress) {
address = ((SOAPAddress) e).getLocationURI();
} else if (e instanceof HTTPAddress) {
address = ((HTTPAddress) e).getLocationURI();
}
}
addPort(name, bindingID, address);
}
} catch (WebServiceException e) {
throw e;
} catch (Throwable e) {
if (e instanceof UncheckedException && LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, e.getLocalizedMessage(), e);
}
WSDLServiceFactory sf = new WSDLServiceFactory(bus, wsdlURL, serviceName);
Service service = sf.create();
for (ServiceInfo si : service.getServiceInfos()) {
for (EndpointInfo ei : si.getEndpoints()) {
String bindingID = BindingID.getJaxwsBindingID(ei.getTransportId());
addPort(ei.getName(), bindingID, ei.getAddress());
}
}
}
}
use of org.apache.cxf.wsdl.http.AddressType in project cxf by apache.
the class JAXWSDefinitionBuilderTest method testBuildDefinitionWithXMLBinding.
@Test
public void testBuildDefinitionWithXMLBinding() {
String qname = "http://apache.org/hello_world_xml_http/bare";
String wsdlUrl = getClass().getResource("resources/hello_world_xml_bare.wsdl").toString();
JAXWSDefinitionBuilder builder = new JAXWSDefinitionBuilder();
builder.setBus(BusFactory.getDefaultBus());
builder.setContext(env);
Definition def = builder.build(wsdlUrl);
assertNotNull(def);
Map<?, ?> services = def.getServices();
assertNotNull(services);
assertEquals(1, services.size());
Service service = (Service) services.get(new QName(qname, "XMLService"));
assertNotNull(service);
Map<?, ?> ports = service.getPorts();
assertNotNull(ports);
assertEquals(1, ports.size());
Port port = service.getPort("XMLPort");
assertNotNull(port);
assertEquals(1, port.getExtensibilityElements().size());
Object obj = port.getExtensibilityElements().get(0);
if (obj instanceof JAXBExtensibilityElement) {
obj = ((JAXBExtensibilityElement) obj).getValue();
}
assertTrue(obj.getClass().getName() + " is not an AddressType", obj instanceof AddressType);
Binding binding = port.getBinding();
assertNotNull(binding);
assertEquals(new QName(qname, "Greeter_XMLBinding"), binding.getQName());
BindingOperation operation = binding.getBindingOperation("sayHi", null, null);
assertNotNull(operation);
BindingInput input = operation.getBindingInput();
assertNotNull(input);
assertEquals(1, input.getExtensibilityElements().size());
obj = input.getExtensibilityElements().get(0);
if (obj instanceof JAXBExtensibilityElement) {
obj = ((JAXBExtensibilityElement) obj).getValue();
}
assertTrue(obj.getClass().getName() + " is not an XMLBindingMessageFormat", obj instanceof XMLBindingMessageFormat);
}
use of org.apache.cxf.wsdl.http.AddressType in project cxf by apache.
the class HTTPTransportFactory method createEndpointInfo.
public EndpointInfo createEndpointInfo(ServiceInfo serviceInfo, BindingInfo b, List<?> ees) {
if (ees != null) {
for (Iterator<?> itr = ees.iterator(); itr.hasNext(); ) {
Object extensor = itr.next();
if (extensor instanceof AddressType) {
final AddressType httpAdd = (AddressType) extensor;
EndpointInfo info = new HttpEndpointInfo(serviceInfo, "http://schemas.xmlsoap.org/wsdl/http/");
info.setAddress(httpAdd.getLocation());
info.addExtensor(httpAdd);
return info;
}
}
}
HttpEndpointInfo hei = new HttpEndpointInfo(serviceInfo, "http://schemas.xmlsoap.org/wsdl/http/");
AddressType at = new AddressType();
hei.addExtensor(at);
return hei;
}
use of org.apache.cxf.wsdl.http.AddressType in project tomee by apache.
the class HTTPTransportFactory method createEndpointInfo.
public EndpointInfo createEndpointInfo(ServiceInfo serviceInfo, BindingInfo b, List<?> ees) {
if (ees != null) {
for (Iterator<?> itr = ees.iterator(); itr.hasNext(); ) {
Object extensor = itr.next();
if (extensor instanceof AddressType) {
final AddressType httpAdd = (AddressType) extensor;
EndpointInfo info = new HttpEndpointInfo(serviceInfo, "http://schemas.xmlsoap.org/wsdl/http/");
info.setAddress(httpAdd.getLocation());
info.addExtensor(httpAdd);
return info;
}
}
}
HttpEndpointInfo hei = new HttpEndpointInfo(serviceInfo, "http://schemas.xmlsoap.org/wsdl/http/");
AddressType at = new AddressType();
hei.addExtensor(at);
return hei;
}
Aggregations