下面列出了怎么用javax.jws.soap.SOAPBinding的API类实例代码及写法,或者点击链接到github查看源代码。
protected SOAPBinding popSoapBinding() {
if (pushedSoapBinding)
soapBindingStack.pop();
SOAPBinding soapBinding = null;
if (!soapBindingStack.empty()) {
soapBinding = soapBindingStack.peek();
if (soapBinding.style().equals(SOAPBinding.Style.RPC)) {
soapStyle = SOAPStyle.RPC;
wrapped = true;
} else {
soapStyle = SOAPStyle.DOCUMENT;
wrapped = soapBinding.parameterStyle().equals(ParameterStyle.WRAPPED);
}
} else {
pushedSoapBinding = false;
}
return soapBinding;
}
/**
* creates a runtime model <code>SOAPBinding</code> from a <code>javax.jws.soap.SOAPBinding</code> object
* @param soapBinding the <code>javax.jws.soap.SOAPBinding</code> to model
* @return returns the runtime model SOAPBinding corresponding to <code>soapBinding</code>
*/
protected SOAPBindingImpl createBinding(SOAPBinding soapBinding) {
SOAPBindingImpl rtSOAPBinding = new SOAPBindingImpl();
Style style = soapBinding!=null ? soapBinding.style() : Style.DOCUMENT;
rtSOAPBinding.setStyle(style);
assert bindingId != null;
model.bindingId = bindingId;
SOAPVersion soapVersion = bindingId.getSOAPVersion();
rtSOAPBinding.setSOAPVersion(soapVersion);
return rtSOAPBinding;
}
protected void preProcessWebService(WebService webService, TypeElement element) {
processedMethods = new HashSet<String>();
seiContext = context.getSeiContext(element);
String targetNamespace = null;
if (webService != null)
targetNamespace = webService.targetNamespace();
PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
if (targetNamespace == null || targetNamespace.length() == 0) {
String packageName = packageElement.getQualifiedName().toString();
if (packageName == null || packageName.length() == 0) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
element.getQualifiedName()), element);
}
targetNamespace = RuntimeModeler.getNamespace(packageName);
}
seiContext.setNamespaceUri(targetNamespace);
if (serviceImplName == null)
serviceImplName = seiContext.getSeiImplName();
if (serviceImplName != null) {
seiContext.setSeiImplName(serviceImplName);
context.addSeiContext(serviceImplName, seiContext);
}
portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
packageName = packageElement.getQualifiedName();
portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
webService.name() : portName;
serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
webService.serviceName() : serviceName;
wsdlNamespace = seiContext.getNamespaceUri();
typeNamespace = wsdlNamespace;
SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
if (soapBinding != null) {
pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
} else if (element.equals(typeElement)) {
pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
}
}
/**
*
* @param body
* @throws DispositionReportFaultMessage
*/
@WebMethod(operationName = "delete_publisher", action = "delete_publisher")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public void deletePublisher(
@WebParam(name = "delete_publisher", targetNamespace = "urn:juddi-apache-org:api_v3", partName = "body")
DeletePublisher body)
throws DispositionReportFaultMessage, RemoteException
;
/**
*
* @param body
* @return
* returns org.apache.juddi.api_v3.PublisherDetail
* @throws DispositionReportFaultMessage
*/
@WebMethod(operationName = "get_allPublisherDetail", action = "get_allPublisherDetail")
@WebResult(name = "publisherDetail", targetNamespace = "urn:juddi-apache-org:api_v3", partName = "body")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public PublisherDetail getAllPublisherDetail(
@WebParam(name = "get_allPublisherDetail", targetNamespace = "urn:juddi-apache-org:api_v3", partName = "body")
GetAllPublisherDetail body)
throws DispositionReportFaultMessage, RemoteException
;
@Override
public Void visitExecutable(ExecutableElement method, Object o) {
// Methods must be public
if (!method.getModifiers().contains(Modifier.PUBLIC))
return null;
if (processedMethod(method))
return null;
WebMethod webMethod = method.getAnnotation(WebMethod.class);
if (webMethod != null && webMethod.exclude())
return null;
SOAPBinding soapBinding = method.getAnnotation(SOAPBinding.class);
if (soapBinding == null && !method.getEnclosingElement().equals(typeElement)) {
if (method.getEnclosingElement().getKind().equals(ElementKind.CLASS)) {
soapBinding = method.getEnclosingElement().getAnnotation(SOAPBinding.class);
if (soapBinding != null)
builder.log("using " + method.getEnclosingElement() + "'s SOAPBinding.");
else {
soapBinding = new MySoapBinding();
}
}
}
boolean newBinding = false;
if (soapBinding != null) {
newBinding = pushSoapBinding(soapBinding, method, typeElement);
}
try {
if (shouldProcessMethod(method, webMethod)) {
processMethod(method, webMethod);
}
} finally {
if (newBinding) {
popSoapBinding();
}
}
return null;
}
protected void preProcessWebService(WebService webService, TypeElement element) {
processedMethods = new HashSet<String>();
seiContext = context.getSeiContext(element);
String targetNamespace = null;
if (webService != null)
targetNamespace = webService.targetNamespace();
PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
if (targetNamespace == null || targetNamespace.length() == 0) {
String packageName = packageElement.getQualifiedName().toString();
if (packageName == null || packageName.length() == 0) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
element.getQualifiedName()), element);
}
targetNamespace = RuntimeModeler.getNamespace(packageName);
}
seiContext.setNamespaceUri(targetNamespace);
if (serviceImplName == null)
serviceImplName = seiContext.getSeiImplName();
if (serviceImplName != null) {
seiContext.setSeiImplName(serviceImplName);
context.addSeiContext(serviceImplName, seiContext);
}
portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
packageName = packageElement.getQualifiedName();
portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
webService.name() : portName;
serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
webService.serviceName() : serviceName;
wsdlNamespace = seiContext.getNamespaceUri();
typeNamespace = wsdlNamespace;
SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
if (soapBinding != null) {
pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
} else if (element.equals(typeElement)) {
pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
}
}
@Test
public void testSupportXMLBindingBare() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/xml_http_bare.wsdl"));
processor.setContext(env);
processor.execute();
Class<?> clz = classLoader.loadClass("org.apache.xml_http_bare.GreetingPortType");
Method method = clz.getMethod("sayHello", new Class[] {java.lang.String.class});
assertNotNull("sayHello is not be generated", method);
SOAPBinding soapBindingAnn = clz.getAnnotation(SOAPBinding.class);
assertEquals(soapBindingAnn.parameterStyle(), SOAPBinding.ParameterStyle.BARE);
}
/**
*
* @param body
* @return
* returns org.apache.juddi.api_v3.PublisherDetail
* @throws DispositionReportFaultMessage
*/
@WebMethod(operationName = "save_publisher", action = "save_publisher")
@WebResult(name = "save_publisherResponse", targetNamespace = "urn:juddi-apache-org:v3_service", partName = "save_publisherResponse")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public PublisherDetail savePublisher(
@WebParam(name = "save_publisher", targetNamespace = "urn:juddi-apache-org:api_v3", partName = "body")
SavePublisher body)
throws DispositionReportFaultMessage, RemoteException
;
/**
* Get the OSD.
*/
@WebMethod(operationName = "GetOSD", action = "http://www.onvif.org/ver10/media/wsdl/GetOSD")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@WebResult(name = "GetOSDResponse", targetNamespace = "http://www.onvif.org/ver10/media/wsdl", partName = "parameters")
public GetOSDResponse getOSD(
@WebParam(partName = "parameters", name = "GetOSD", targetNamespace = "http://www.onvif.org/ver10/media/wsdl")
GetOSD parameters
);
/**
* Request the VideoSourceConfigurationOptions of a VideoSource. A device
* with one or more video sources shall support this command.
*
*/
@WebMethod(operationName = "GetVideoSourceConfigurationOptions", action = "http://www.onvif.org/ver10/deviceio/wsdl/GetVideoSourceConfigurationOptions")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@WebResult(name = "GetVideoSourceConfigurationOptionsResponse", targetNamespace = "http://www.onvif.org/ver10/deviceIO/wsdl", partName = "parameters")
public GetVideoSourceConfigurationOptionsResponse getVideoSourceConfigurationOptions(
@WebParam(partName = "parameters", name = "GetVideoSourceConfigurationOptions", targetNamespace = "http://www.onvif.org/ver10/deviceIO/wsdl")
GetVideoSourceConfigurationOptions parameters
);
@Test
public void testAnnotateDOCWrapped() throws Exception {
init(method, parameter, SOAPBinding.Style.DOCUMENT, true);
parameter.annotate(new WebParamAnnotator());
JAnnotation annotation = parameter.getAnnotation("WebParam");
assertEquals("@WebParam(name = \"x\", targetNamespace = \"http://apache.org/cxf\")",
annotation.toString());
List<JAnnotationElement> elements = annotation.getElements();
assertEquals(2, elements.size());
assertEquals("http://apache.org/cxf", elements.get(1).getValue());
assertEquals("x", elements.get(0).getValue());
}
/**
* Modify a video input configuration. A device that has one or more video
* sources shall support the setting of the VideoSourceConfiguration through this command.
*
*/
@WebMethod(operationName = "SetVideoSourceConfiguration", action = "http://www.onvif.org/ver10/deviceio/wsdl/SetVideoSourceConfiguration")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@WebResult(name = "SetVideoSourceConfigurationResponse", targetNamespace = "http://www.onvif.org/ver10/deviceIO/wsdl", partName = "parameters")
public SetVideoSourceConfigurationResponse setVideoSourceConfiguration(
@WebParam(partName = "parameters", name = "SetVideoSourceConfiguration", targetNamespace = "http://www.onvif.org/ver10/deviceIO/wsdl")
SetVideoSourceConfiguration parameters
);
/**
*
* @param body
* @return
* returns org.apache.juddi.api_v3.NodeDetail
* @throws DispositionReportFaultMessage
*/
@WebMethod(operationName = "save_Node", action = "save_Node")
@WebResult(name = "save_NodeResponse", targetNamespace = "urn:juddi-apache-org:v3_service", partName = "save_NodeResponse")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public NodeDetail saveNode(
@WebParam(name = "save_NodeRequest", targetNamespace = "urn:juddi-apache-org:api_v3", partName = "body")
SaveNode body)
throws DispositionReportFaultMessage, RemoteException
;
@Override
public Void visitExecutable(ExecutableElement method, Object o) {
// Methods must be public
if (!method.getModifiers().contains(Modifier.PUBLIC))
return null;
if (processedMethod(method))
return null;
WebMethod webMethod = method.getAnnotation(WebMethod.class);
if (webMethod != null && webMethod.exclude())
return null;
SOAPBinding soapBinding = method.getAnnotation(SOAPBinding.class);
if (soapBinding == null && !method.getEnclosingElement().equals(typeElement)) {
if (method.getEnclosingElement().getKind().equals(ElementKind.CLASS)) {
soapBinding = method.getEnclosingElement().getAnnotation(SOAPBinding.class);
if (soapBinding != null)
builder.log("using " + method.getEnclosingElement() + "'s SOAPBinding.");
else {
soapBinding = new MySoapBinding();
}
}
}
boolean newBinding = false;
if (soapBinding != null) {
newBinding = pushSoapBinding(soapBinding, method, typeElement);
}
try {
if (shouldProcessMethod(method, webMethod)) {
processMethod(method, webMethod);
}
} finally {
if (newBinding) {
popSoapBinding();
}
}
return null;
}
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@WebResult(name = "GetSubscriptionIDsResult", targetNamespace = "urn:epcglobal:epcis-query:xsd:1", partName = "getSubscriptionIDsReturn")
@WebMethod
public org.fosstrak.epcis.model.ArrayOfString getSubscriptionIDs(
@WebParam(partName = "parms", name = "GetSubscriptionIDs", targetNamespace = "urn:epcglobal:epcis-query:xsd:1")
org.fosstrak.epcis.model.GetSubscriptionIDs parms) throws ImplementationExceptionResponse,
SecurityExceptionResponse, ValidationExceptionResponse, NoSuchNameExceptionResponse;
/**
* List the configuration of an Audio Input. A device with one or more audio
* inputs shall support the GetAudioSourceConfiguration command.
*
*/
@WebMethod(operationName = "GetAudioSourceConfiguration", action = "http://www.onvif.org/ver10/deviceio/wsdl/GetAudioSourceConfiguration")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@WebResult(name = "GetAudioSourceConfigurationResponse", targetNamespace = "http://www.onvif.org/ver10/deviceIO/wsdl", partName = "parameters")
public GetAudioSourceConfigurationResponse getAudioSourceConfiguration(
@WebParam(partName = "parameters", name = "GetAudioSourceConfiguration", targetNamespace = "http://www.onvif.org/ver10/deviceIO/wsdl")
GetAudioSourceConfiguration parameters
);
@Override
public Boolean isWrapped() {
SOAPBinding ann = implInfo.getEndpointClass().getAnnotation(SOAPBinding.class);
if (ann != null) {
return !(ann.parameterStyle().equals(ParameterStyle.BARE) || ann.style().equals(Style.RPC));
}
return null;
}
@Override
public String getStyle() {
SOAPBinding ann = implInfo.getEndpointClass().getAnnotation(SOAPBinding.class);
if (ann != null) {
return ann.style().toString().toLowerCase();
}
return super.getStyle();
}
/**
*
* @param body
* @throws DispositionReportFaultMessage
*/
@WebMethod(operationName = "adminDelete_tModel", action = "adminDelete_tmodel")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public void adminDeleteTModel(
@WebParam(name = "adminDelete_tmodel", targetNamespace = "urn:juddi-apache-org:api_v3", partName = "body")
DeleteTModel body)
throws DispositionReportFaultMessage, RemoteException
;
protected void preProcessWebService(WebService webService, TypeElement element) {
processedMethods = new HashSet<String>();
seiContext = context.getSeiContext(element);
String targetNamespace = null;
if (webService != null)
targetNamespace = webService.targetNamespace();
PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
if (targetNamespace == null || targetNamespace.length() == 0) {
String packageName = packageElement.getQualifiedName().toString();
if (packageName == null || packageName.length() == 0) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
element.getQualifiedName()), element);
}
targetNamespace = RuntimeModeler.getNamespace(packageName);
}
seiContext.setNamespaceUri(targetNamespace);
if (serviceImplName == null)
serviceImplName = seiContext.getSeiImplName();
if (serviceImplName != null) {
seiContext.setSeiImplName(serviceImplName);
context.addSeiContext(serviceImplName, seiContext);
}
portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
packageName = packageElement.getQualifiedName();
portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
webService.name() : portName;
serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
webService.serviceName() : serviceName;
wsdlNamespace = seiContext.getNamespaceUri();
typeNamespace = wsdlNamespace;
SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
if (soapBinding != null) {
pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
} else if (element.equals(typeElement)) {
pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
}
}
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@WebResult(name = "QueryResults", targetNamespace = "urn:epcglobal:epcis-query:xsd:1", partName = "pollReturn")
@WebMethod
public org.fosstrak.epcis.model.QueryResults poll(
@WebParam(partName = "parms", name = "Poll", targetNamespace = "urn:epcglobal:epcis-query:xsd:1")
org.fosstrak.epcis.model.Poll parms) throws ImplementationExceptionResponse,
QueryTooComplexExceptionResponse, QueryTooLargeExceptionResponse, SecurityExceptionResponse,
ValidationExceptionResponse, NoSuchNameExceptionResponse, QueryParameterExceptionResponse;
/**
* Modify an audio output configuration. A device that has one ore more audio
* outputs shall support the setting of the AudioOutputConfiguration through this command.
*
*/
@WebMethod(operationName = "SetAudioOutputConfiguration", action = "http://www.onvif.org/ver10/deviceio/wsdl/SetAudioOutputConfiguration")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@WebResult(name = "SetAudioOutputConfigurationResponse", targetNamespace = "http://www.onvif.org/ver10/deviceIO/wsdl", partName = "parameters")
public SetAudioOutputConfigurationResponse setAudioOutputConfiguration(
@WebParam(partName = "parameters", name = "SetAudioOutputConfiguration", targetNamespace = "http://www.onvif.org/ver10/deviceIO/wsdl")
SetAudioOutputConfiguration parameters
);
private boolean isRPCEncoded(Definition def) {
Iterator<?> ite1 = def.getBindings().values().iterator();
while (ite1.hasNext()) {
Binding binding = (Binding)ite1.next();
String bindingStyle = SOAPBindingUtil.getBindingStyle(binding);
Iterator<?> ite2 = binding.getBindingOperations().iterator();
while (ite2.hasNext()) {
BindingOperation bop = (BindingOperation)ite2.next();
String bopStyle = SOAPBindingUtil.getSOAPOperationStyle(bop);
String outputUse = "";
if (SOAPBindingUtil.getBindingOutputSOAPBody(bop) != null) {
outputUse = SOAPBindingUtil.getBindingOutputSOAPBody(bop).getUse();
}
String inputUse = "";
if (SOAPBindingUtil.getBindingInputSOAPBody(bop) != null) {
inputUse = SOAPBindingUtil.getBindingInputSOAPBody(bop).getUse();
}
if ((SOAPBinding.Style.RPC.name().equalsIgnoreCase(bindingStyle) || SOAPBinding.Style.RPC
.name().equalsIgnoreCase(bopStyle))
&& (SOAPBinding.Use.ENCODED.name().equalsIgnoreCase(inputUse) || SOAPBinding.Use.ENCODED
.name().equalsIgnoreCase(outputUse))) {
return true;
}
}
}
return false;
}
/**
* creates a runtime model <code>SOAPBinding</code> from a <code>javax.jws.soap.SOAPBinding</code> object
* @param soapBinding the <code>javax.jws.soap.SOAPBinding</code> to model
* @return returns the runtime model SOAPBinding corresponding to <code>soapBinding</code>
*/
protected SOAPBindingImpl createBinding(SOAPBinding soapBinding) {
SOAPBindingImpl rtSOAPBinding = new SOAPBindingImpl();
Style style = soapBinding!=null ? soapBinding.style() : Style.DOCUMENT;
rtSOAPBinding.setStyle(style);
assert bindingId != null;
model.bindingId = bindingId;
SOAPVersion soapVersion = bindingId.getSOAPVersion();
rtSOAPBinding.setSOAPVersion(soapVersion);
return rtSOAPBinding;
}
private void writeSOAPBinding(Port port, JDefinedClass cls) {
JAnnotationUse soapBindingAnn = null;
isDocStyle = port.getStyle() == null || port.getStyle().equals(SOAPStyle.DOCUMENT);
if(!isDocStyle){
soapBindingAnn = cls.annotate(SOAPBinding.class);
soapBindingAnn.param("style", SOAPBinding.Style.RPC);
port.setWrapped(true);
}
if(isDocStyle){
boolean first = true;
boolean isWrapper = true;
for(Operation operation:port.getOperations()){
if(first){
isWrapper = operation.isWrapped();
first = false;
continue;
}
sameParamStyle = (isWrapper == operation.isWrapped());
if (!sameParamStyle) {
break;
}
}
if (sameParamStyle) {
port.setWrapped(isWrapper);
}
}
if(sameParamStyle && !port.isWrapped()){
if (soapBindingAnn == null) {
soapBindingAnn = cls.annotate(SOAPBinding.class);
}
soapBindingAnn.param("parameterStyle", SOAPBinding.ParameterStyle.BARE);
}
}
protected void preProcessWebService(WebService webService, TypeElement element) {
processedMethods = new HashSet<String>();
seiContext = context.getSeiContext(element);
String targetNamespace = null;
if (webService != null)
targetNamespace = webService.targetNamespace();
PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
if (targetNamespace == null || targetNamespace.length() == 0) {
String packageName = packageElement.getQualifiedName().toString();
if (packageName == null || packageName.length() == 0) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
element.getQualifiedName()), element);
}
targetNamespace = RuntimeModeler.getNamespace(packageName);
}
seiContext.setNamespaceUri(targetNamespace);
if (serviceImplName == null)
serviceImplName = seiContext.getSeiImplName();
if (serviceImplName != null) {
seiContext.setSeiImplName(serviceImplName);
context.addSeiContext(serviceImplName, seiContext);
}
portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
packageName = packageElement.getQualifiedName();
portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
webService.name() : portName;
serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
webService.serviceName() : serviceName;
wsdlNamespace = seiContext.getNamespaceUri();
typeNamespace = wsdlNamespace;
SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
if (soapBinding != null) {
pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
} else if (element.equals(typeElement)) {
pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
}
}
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@WebResult(name = "GetQueryNamesResult", targetNamespace = "urn:epcglobal:epcis-query:xsd:1", partName = "getQueryNamesReturn")
@WebMethod
public org.fosstrak.epcis.model.ArrayOfString getQueryNames(
@WebParam(partName = "parms", name = "GetQueryNames", targetNamespace = "urn:epcglobal:epcis-query:xsd:1")
org.fosstrak.epcis.model.EmptyParms parms) throws ImplementationExceptionResponse, SecurityExceptionResponse,
ValidationExceptionResponse;
@Override
public Void visitExecutable(ExecutableElement method, Object o) {
// Methods must be public
if (!method.getModifiers().contains(Modifier.PUBLIC))
return null;
if (processedMethod(method))
return null;
WebMethod webMethod = method.getAnnotation(WebMethod.class);
if (webMethod != null && webMethod.exclude())
return null;
SOAPBinding soapBinding = method.getAnnotation(SOAPBinding.class);
if (soapBinding == null && !method.getEnclosingElement().equals(typeElement)) {
if (method.getEnclosingElement().getKind().equals(ElementKind.CLASS)) {
soapBinding = method.getEnclosingElement().getAnnotation(SOAPBinding.class);
if (soapBinding != null)
builder.log("using " + method.getEnclosingElement() + "'s SOAPBinding.");
else {
soapBinding = new MySoapBinding();
}
}
}
boolean newBinding = false;
if (soapBinding != null) {
newBinding = pushSoapBinding(soapBinding, method, typeElement);
}
try {
if (shouldProcessMethod(method, webMethod)) {
processMethod(method, webMethod);
}
} finally {
if (newBinding) {
popSoapBinding();
}
}
return null;
}
@Test
public void testHolderHeader() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world_holder.wsdl"));
env.remove(ToolConstants.CFG_VALIDATE_WSDL); // testing multiple parts in body
processor.setContext(env);
processor.execute();
Class<?> clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_holder.Greeter");
assertEquals(2, clz.getMethods().length);
Class<?> para = classLoader.loadClass("org.apache.cxf.w2j.hello_world_holder.types.GreetMe");
Method method = clz.getMethod("sayHi", new Class[] {Holder.class, para});
assertEquals("GreetMeResponse", method.getReturnType().getSimpleName());
SOAPBinding soapBindingAnno = AnnotationUtil.getPrivClassAnnotation(clz, SOAPBinding.class);
if (soapBindingAnno == null) {
soapBindingAnno = method.getAnnotation(SOAPBinding.class);
}
assertNotNull(soapBindingAnno);
assertEquals("BARE", soapBindingAnno.parameterStyle().name());
assertEquals("LITERAL", soapBindingAnno.use().name());
assertEquals("DOCUMENT", soapBindingAnno.style().name());
WebParam webParamAnno = AnnotationUtil.getWebParam(method, "greetMe");
assertTrue(webParamAnno.header());
webParamAnno = AnnotationUtil.getWebParam(method, "sayHi");
assertEquals("INOUT", webParamAnno.mode().name());
method = clz.getMethod("testInOut", Holder.class, Integer.TYPE);
}