use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class ProxyTest method testCreateSequenceResponse.
@Test
public void testCreateSequenceResponse() throws NoSuchMethodException, RMException {
Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] { OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class });
Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
proxy.setReliableEndpoint(rme);
Endpoint endpoint = control.createMock(Endpoint.class);
EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
EndpointInfo epi = control.createMock(EndpointInfo.class);
EasyMock.expect(endpoint.getEndpointInfo()).andReturn(epi).anyTimes();
ServiceInfo si = control.createMock(ServiceInfo.class);
EasyMock.expect(epi.getService()).andReturn(si).anyTimes();
InterfaceInfo ii = control.createMock(InterfaceInfo.class);
EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
OperationInfo oi = control.createMock(OperationInfo.class);
EasyMock.expect(ii.getOperation(RM10Constants.CREATE_SEQUENCE_RESPONSE_ONEWAY_QNAME)).andReturn(oi).anyTimes();
org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType csr = control.createMock(org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType.class);
expectInvoke(proxy, oi, null);
control.replay();
proxy.createSequenceResponse(csr, ProtocolVariation.RM10WSA200408);
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class RMEndpoint method buildSequenceAckOperationInfo.
void buildSequenceAckOperationInfo(InterfaceInfo ii, ProtocolVariation protocol) {
OperationInfo operationInfo = null;
MessageInfo messageInfo = null;
RMConstants consts = protocol.getConstants();
operationInfo = ii.addOperation(consts.getSequenceAckOperationName());
messageInfo = operationInfo.createMessage(consts.getSequenceAckOperationName(), MessageInfo.Type.INPUT);
operationInfo.setInput(messageInfo.getName().getLocalPart(), messageInfo);
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class RMEndpoint method buildAckRequestedOperationInfo.
void buildAckRequestedOperationInfo(InterfaceInfo ii, ProtocolVariation protocol) {
OperationInfo operationInfo = null;
MessageInfo messageInfo = null;
RMConstants consts = protocol.getConstants();
operationInfo = ii.addOperation(consts.getAckRequestedOperationName());
messageInfo = operationInfo.createMessage(consts.getAckRequestedOperationName(), MessageInfo.Type.INPUT);
operationInfo.setInput(messageInfo.getName().getLocalPart(), messageInfo);
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class ServiceProcessor method processOperation.
private void processOperation(JavaModel model, BindingOperationInfo bop, BindingInfo binding) throws ToolException {
boolean enableOpMime = false;
JAXWSBinding bind = binding.getExtensor(JAXWSBinding.class);
if (bind != null && bind.isEnableMime()) {
enableOpMime = true;
}
JAXWSBinding bopBinding = bop.getExtensor(JAXWSBinding.class);
if (bopBinding != null && bopBinding.isEnableMime()) {
enableOpMime = true;
if (bopBinding.getJaxwsParas() != null) {
jaxwsBinding.setJaxwsParas(bopBinding.getJaxwsParas());
}
}
JavaInterface jf = null;
for (JavaInterface jf2 : model.getInterfaces().values()) {
if (binding.getInterface().getName().getLocalPart().equals(jf2.getWebServiceName())) {
jf = jf2;
}
}
if (jf == null) {
throw new ToolException("No Java Interface available");
}
if (isSoapBinding()) {
SoapBinding soapBinding = (SoapBinding) bindingObj;
if (SOAPBindingUtil.getSoapStyle(soapBinding.getStyle()) == null) {
jf.setSOAPStyle(javax.jws.soap.SOAPBinding.Style.DOCUMENT);
} else {
jf.setSOAPStyle(SOAPBindingUtil.getSoapStyle(soapBinding.getStyle()));
}
} else {
// REVISIT: fix for xml binding
jf.setSOAPStyle(javax.jws.soap.SOAPBinding.Style.DOCUMENT);
}
Object[] methods = jf.getMethods().toArray();
for (int i = 0; i < methods.length; i++) {
JavaMethod jm = (JavaMethod) methods[i];
if (jm.getOperationName() != null && jm.getOperationName().equals(bop.getName().getLocalPart())) {
if (isSoapBinding()) {
// TODO: add customize here
// doCustomizeOperation(jf, jm, bop);
Map<String, Object> prop = getSoapOperationProp(bop);
String soapAction = prop.get(soapOPAction) == null ? "" : (String) prop.get(soapOPAction);
String soapStyle = prop.get(soapOPStyle) == null ? "" : (String) prop.get(soapOPStyle);
jm.setSoapAction(soapAction);
if (SOAPBindingUtil.getSoapStyle(soapStyle) == null && this.bindingObj == null) {
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("BINDING_STYLE_NOT_DEFINED", LOG);
throw new ToolException(msg);
}
if (SOAPBindingUtil.getSoapStyle(soapStyle) == null) {
jm.setSoapStyle(jf.getSOAPStyle());
} else {
jm.setSoapStyle(SOAPBindingUtil.getSoapStyle(soapStyle));
}
} else {
// REVISIT: fix for xml binding
jm.setSoapStyle(jf.getSOAPStyle());
}
if (jm.getSoapStyle().equals(javax.jws.soap.SOAPBinding.Style.RPC)) {
jm.getAnnotationMap().remove("SOAPBinding");
}
OperationProcessor processor = new OperationProcessor(context);
int headerType = isNonWrappable(bop);
OperationInfo opinfo = bop.getOperationInfo();
JAXWSBinding opBinding = opinfo.getExtensor(JAXWSBinding.class);
JAXWSBinding infBinding = opinfo.getInterface().getExtensor(JAXWSBinding.class);
boolean enableMime = enableOpMime;
boolean enableWrapperStyle = true;
if (infBinding != null && infBinding.isSetEnableWrapperStyle()) {
enableWrapperStyle = infBinding.isEnableWrapperStyle();
}
if (infBinding != null && infBinding.isSetEnableMime()) {
enableMime = infBinding.isEnableMime();
}
if (opBinding != null && opBinding.isSetEnableWrapperStyle()) {
enableWrapperStyle = opBinding.isEnableWrapperStyle();
}
if (opBinding != null && opBinding.isSetEnableMime()) {
enableMime = opBinding.isEnableMime();
}
if (jaxwsBinding.isEnableMime() || enableMime) {
jm.setMimeEnable(true);
}
if ((jm.isWrapperStyle() && headerType > this.noHEADER) || !jaxwsBinding.isEnableWrapperStyle() || (jm.enableMime() && jm.isWrapperStyle()) || !enableWrapperStyle) {
// changed wrapper style
jm.setWrapperStyle(false);
processor.processMethod(jm, bop.getOperationInfo());
jm.getAnnotationMap().remove("ResponseWrapper");
jm.getAnnotationMap().remove("RequestWrapper");
} else {
processor.processMethod(jm, bop.getOperationInfo());
}
if (headerType == this.resultHeader) {
JAnnotation resultAnno = jm.getAnnotationMap().get("WebResult");
if (resultAnno != null) {
resultAnno.addElement(new JAnnotationElement("header", true, true));
}
}
processParameter(jm, bop);
}
}
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class RequestWrapperTest method testBuildRequestFields.
@Test
public void testBuildRequestFields() {
// Test String[]
Class<?> testingClass = GreeterArray.class;
OperationInfo opInfo = getOperation(testingClass, "sayStringArray");
assertNotNull(opInfo);
RequestWrapper requestWrapper = new RequestWrapper();
MessageInfo message = opInfo.getUnwrappedOperation().getInput();
Method method = (Method) opInfo.getProperty("operation.method");
List<JavaField> fields = requestWrapper.buildFields(method, message);
assertEquals(1, fields.size());
JavaField field = fields.get(0);
assertEquals("arg0", field.getName());
assertEquals("String[]", field.getType());
// Test int[]
opInfo = getOperation(testingClass, "sayIntArray");
assertNotNull(opInfo);
message = opInfo.getUnwrappedOperation().getInput();
method = (Method) opInfo.getProperty("operation.method");
fields = requestWrapper.buildFields(method, message);
assertEquals(1, fields.size());
field = fields.get(0);
assertEquals("arg0", field.getName());
assertEquals("int[]", field.getType());
// Test TestDataBean[]
opInfo = getOperation(testingClass, "sayTestDataBeanArray");
assertNotNull(opInfo);
message = opInfo.getUnwrappedOperation().getInput();
method = (Method) opInfo.getProperty("operation.method");
fields = requestWrapper.buildFields(method, message);
assertEquals(1, fields.size());
field = fields.get(0);
assertEquals("arg0", field.getName());
assertEquals("org.apache.cxf.tools.fortest.withannotation.doc.TestDataBean[]", field.getType());
}
Aggregations