use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class ComplexClient method main.
/**
* @param args
*/
public static void main(String[] args) throws Exception {
if (args.length == 0) {
System.out.println("please specify wsdl");
System.exit(1);
}
URL wsdlURL;
File wsdlFile = new File(args[0]);
if (wsdlFile.exists()) {
wsdlURL = wsdlFile.toURI().toURL();
} else {
wsdlURL = new URL(args[0]);
}
System.out.println(wsdlURL);
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
Client client = factory.createClient(wsdlURL.toExternalForm(), SERVICE_NAME);
ClientImpl clientImpl = (ClientImpl) client;
Endpoint endpoint = clientImpl.getEndpoint();
ServiceInfo serviceInfo = endpoint.getService().getServiceInfos().get(0);
QName bindingName = new QName("http://Company.com/Application", "Company_ESB_Application_Biztalk_AgentDetails_4405_AgentDetails_PrtSoap");
BindingInfo binding = serviceInfo.getBinding(bindingName);
// {
QName opName = new QName("http://Company.com/Application", "GetAgentDetails");
BindingOperationInfo boi = binding.getOperation(opName);
BindingMessageInfo inputMessageInfo = boi.getInput();
List<MessagePartInfo> parts = inputMessageInfo.getMessageParts();
// only one part.
MessagePartInfo partInfo = parts.get(0);
Class<?> partClass = partInfo.getTypeClass();
// GetAgentDetails
System.out.println(partClass.getCanonicalName());
Object inputObject = partClass.newInstance();
// Unfortunately, the slot inside of the part object is also called 'part'.
// this is the descriptor for get/set part inside the GetAgentDetails class.
PropertyDescriptor partPropertyDescriptor = new PropertyDescriptor("part", partClass);
// This is the type of the class which really contains all the parameter information.
// AgentWSRequest
Class<?> partPropType = partPropertyDescriptor.getPropertyType();
System.out.println(partPropType.getCanonicalName());
Object inputPartObject = partPropType.newInstance();
partPropertyDescriptor.getWriteMethod().invoke(inputObject, inputPartObject);
PropertyDescriptor numberPropertyDescriptor = new PropertyDescriptor("agentNumber", partPropType);
numberPropertyDescriptor.getWriteMethod().invoke(inputPartObject, Integer.valueOf(314159));
Object[] result = client.invoke(opName, inputObject);
Class<?> resultClass = result[0].getClass();
// GetAgentDetailsResponse
System.out.println(resultClass.getCanonicalName());
PropertyDescriptor resultDescriptor = new PropertyDescriptor("agentWSResponse", resultClass);
Object wsResponse = resultDescriptor.getReadMethod().invoke(result[0]);
Class<?> wsResponseClass = wsResponse.getClass();
System.out.println(wsResponseClass.getCanonicalName());
PropertyDescriptor agentNameDescriptor = new PropertyDescriptor("agentName", wsResponseClass);
String agentName = (String) agentNameDescriptor.getReadMethod().invoke(wsResponse);
System.out.println("Agent name: " + agentName);
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class CorbaStreamInInterceptor method handleRequest.
private void handleRequest(Message msg) {
ORB orb;
ServiceInfo service;
CorbaDestination destination;
if (msg.getDestination() != null) {
destination = (CorbaDestination) msg.getDestination();
} else {
destination = (CorbaDestination) msg.getExchange().getDestination();
}
service = destination.getBindingInfo().getService();
CorbaMessage message = (CorbaMessage) msg;
Exchange exchange = message.getExchange();
CorbaTypeMap typeMap = message.getCorbaTypeMap();
BindingInfo bInfo = destination.getBindingInfo();
InterfaceInfo info = bInfo.getInterface();
String opName = exchange.get(String.class);
Iterator<BindingOperationInfo> i = bInfo.getOperations().iterator();
OperationType opType = null;
BindingOperationInfo bopInfo = null;
QName opQName = null;
while (i.hasNext()) {
bopInfo = i.next();
if (bopInfo.getName().getLocalPart().equals(opName)) {
opType = bopInfo.getExtensor(OperationType.class);
opQName = bopInfo.getName();
break;
}
}
if (opType == null) {
throw new RuntimeException("Couldn't find the binding operation for " + opName);
}
orb = exchange.get(ORB.class);
ServerRequest request = exchange.get(ServerRequest.class);
NVList list = prepareArguments(message, info, opType, opQName, typeMap, destination, service);
request.arguments(list);
message.setList(list);
HandlerIterator paramIterator = new HandlerIterator(message, true);
final CorbaTypeEventProducer eventProducer;
BindingMessageInfo msgInfo = bopInfo.getInput();
boolean wrap = false;
if (bopInfo.isUnwrappedCapable()) {
wrap = true;
}
if (wrap) {
// wrapper element around our args
QName wrapperElementQName = msgInfo.getMessageInfo().getName();
eventProducer = new WrappedParameterSequenceEventProducer(wrapperElementQName, paramIterator, service, orb);
} else {
eventProducer = new ParameterEventProducer(paramIterator, service, orb);
}
CorbaStreamReader reader = new CorbaStreamReader(eventProducer);
message.setContent(XMLStreamReader.class, reader);
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class CorbaStreamInInterceptor method prepareArguments.
protected NVList prepareArguments(CorbaMessage corbaMsg, InterfaceInfo info, OperationType opType, QName opQName, CorbaTypeMap typeMap, CorbaDestination destination, ServiceInfo service) {
BindingInfo bInfo = destination.getBindingInfo();
EndpointInfo eptInfo = destination.getEndPointInfo();
BindingOperationInfo bOpInfo = bInfo.getOperation(opQName);
OperationInfo opInfo = bOpInfo.getOperationInfo();
Exchange exg = corbaMsg.getExchange();
exg.put(BindingInfo.class, bInfo);
exg.put(InterfaceInfo.class, info);
exg.put(EndpointInfo.class, eptInfo);
exg.put(EndpointReferenceType.class, destination.getAddress());
exg.put(ServiceInfo.class, service);
exg.put(BindingOperationInfo.class, bOpInfo);
exg.put(OperationInfo.class, opInfo);
exg.put(MessageInfo.class, opInfo.getInput());
exg.put(String.class, opQName.getLocalPart());
exg.setInMessage(corbaMsg);
corbaMsg.put(MessageInfo.class, opInfo.getInput());
List<ParamType> paramTypes = opType.getParam();
CorbaStreamable[] arguments = new CorbaStreamable[paramTypes.size()];
return prepareDIIArgsList(corbaMsg, bOpInfo, arguments, paramTypes, typeMap, exg.get(ORB.class), service);
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class ColocMessageObserverTest method testSetExchangeProperties.
@Test
public void testSetExchangeProperties() throws Exception {
QName opName = new QName("A", "B");
msg.put(Message.WSDL_OPERATION, opName);
EasyMock.expect(ep.getService()).andReturn(srv);
Binding binding = control.createMock(Binding.class);
EasyMock.expect(ep.getBinding()).andReturn(binding);
EndpointInfo ei = control.createMock(EndpointInfo.class);
EasyMock.expect(ep.getEndpointInfo()).andReturn(ei);
BindingInfo bi = control.createMock(BindingInfo.class);
EasyMock.expect(ei.getBinding()).andReturn(bi);
BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
EasyMock.expect(bi.getOperation(opName)).andReturn(boi);
EasyMock.expect(bus.getExtension(ClassLoader.class)).andReturn(this.getClass().getClassLoader());
control.replay();
observer = new ColocMessageObserver(ep, bus);
observer.setExchangeProperties(ex, msg);
control.verify();
assertNotNull("Bus should be set", ex.getBus());
assertNotNull("Endpoint should be set", ex.getEndpoint());
assertNotNull("Binding should be set", ex.getBinding());
assertNotNull("Service should be set", ex.getService());
assertNotNull("BindingOperationInfo should be set", ex.getBindingOperationInfo());
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class ColocOutInterceptorTest method verifyIsColocatedWithSameOperation.
private void verifyIsColocatedWithSameOperation() {
colocOut = new TestColocOutInterceptor1();
// Funtion Param
Server s1 = control.createMock(Server.class);
List<Server> list = new ArrayList<>();
list.add(s1);
Endpoint sep = control.createMock(Endpoint.class);
BindingOperationInfo sboi = control.createMock(BindingOperationInfo.class);
// Local var
Service ses = control.createMock(Service.class);
EndpointInfo sei = control.createMock(EndpointInfo.class);
BindingInfo rbi = control.createMock(BindingInfo.class);
Endpoint rep = control.createMock(Endpoint.class);
Service res = control.createMock(Service.class);
EndpointInfo rei = control.createMock(EndpointInfo.class);
BindingOperationInfo rboi = control.createMock(BindingOperationInfo.class);
QName op = new QName("E", "F");
QName intf = new QName("G", "H");
QName inmi = new QName("M", "in");
QName outmi = new QName("M", "out");
ServiceInfo ssi = new ServiceInfo();
InterfaceInfo sii = new InterfaceInfo(ssi, intf);
sii.addOperation(op);
OperationInfo soi = sii.getOperation(op);
MessageInfo mii = new MessageInfo(soi, MessageInfo.Type.INPUT, inmi);
MessageInfo mio = new MessageInfo(soi, MessageInfo.Type.OUTPUT, outmi);
soi.setInput("in", mii);
soi.setOutput("out", mio);
ServiceInfo rsi = new ServiceInfo();
InterfaceInfo rii = new InterfaceInfo(rsi, intf);
rii.addOperation(op);
OperationInfo roi = rii.getOperation(op);
roi.setInput("in", mii);
roi.setOutput("out", mio);
EasyMock.expect(sep.getService()).andReturn(ses);
EasyMock.expect(sep.getEndpointInfo()).andReturn(sei);
EasyMock.expect(s1.getEndpoint()).andReturn(rep);
EasyMock.expect(rep.getService()).andReturn(res);
EasyMock.expect(rep.getEndpointInfo()).andReturn(rei);
EasyMock.expect(ses.getName()).andReturn(new QName("A", "B"));
EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));
EasyMock.expect(rei.getName()).andReturn(new QName("C", "D"));
EasyMock.expect(sei.getName()).andReturn(new QName("C", "D"));
EasyMock.expect(rei.getBinding()).andReturn(rbi);
EasyMock.expect(sboi.getName()).andReturn(op);
EasyMock.expect(sboi.getOperationInfo()).andReturn(soi);
EasyMock.expect(rboi.getName()).andReturn(op);
EasyMock.expect(rboi.getOperationInfo()).andReturn(roi);
EasyMock.expect(rbi.getOperation(op)).andReturn(rboi);
control.replay();
Server val = colocOut.isColocated(list, sep, sboi);
assertEquals("Expecting a colocated call", s1, val);
control.reset();
}
Aggregations