use of com.webcohesion.enunciate.modules.jaxws.model.EndpointInterface in project enunciate by stoicflame.
the class WsdlInfo method getWebMessages.
public List<WebMessage> getWebMessages() {
ArrayList<WebMessage> messages = new ArrayList<WebMessage>();
HashSet<String> foundFaults = new HashSet<String>();
for (EndpointInterface ei : getEndpointInterfaces()) {
Collection<WebMethod> webMethods = ei.getWebMethods();
for (WebMethod method : webMethods) {
for (WebMessage webMessage : method.getMessages()) {
if (webMessage.isFault() && !foundFaults.add(((WebFault) webMessage).getQualifiedName().toString())) {
continue;
}
messages.add(webMessage);
}
}
}
return messages;
}
use of com.webcohesion.enunciate.modules.jaxws.model.EndpointInterface in project enunciate by stoicflame.
the class CSharpXMLClientModule method usesUnmappableElements.
protected boolean usesUnmappableElements() {
boolean usesUnmappableElements = false;
if (this.jaxwsModule != null && this.jaxwsModule.getJaxwsContext() != null) {
for (EndpointInterface ei : this.jaxwsModule.getJaxwsContext().getEndpointInterfaces()) {
Map<String, javax.lang.model.element.Element> paramsByName = new HashMap<String, javax.lang.model.element.Element>();
for (WebMethod webMethod : ei.getWebMethods()) {
for (WebParam webParam : webMethod.getWebParameters()) {
// no out or in/out non-header parameters!
if (webParam.isHeader()) {
// unique parameter names for all header parameters of a given ei
javax.lang.model.element.Element conflict = paramsByName.put(webParam.getElementName(), webParam);
if (conflict != null) {
warn("%s: C# requires that all header parameters defined in the same endpoint interface have unique names. This parameter conflicts with the one at %s.", positionOf(webParam), positionOf(conflict));
usesUnmappableElements = true;
}
DecoratedTypeMirror paramType = (DecoratedTypeMirror) webParam.getType();
if (paramType.isCollection()) {
warn("%s: C# can't handle header parameters that are collections.", positionOf(webParam));
usesUnmappableElements = true;
}
} else if (webParam.getMode() != javax.jws.WebParam.Mode.IN) {
warn("%s: C# doesn't support non-header parameters of mode %s.", positionOf(webParam), webParam.getMode());
usesUnmappableElements = true;
}
// parameters/results can't be maps
if (webParam.getType() instanceof MapType) {
warn("%s: C# can't handle parameter types that are maps.", positionOf(webParam));
usesUnmappableElements = true;
}
}
// web result cannot be a header.
if (webMethod.getWebResult().isHeader()) {
javax.lang.model.element.Element conflict = paramsByName.put(webMethod.getWebResult().getElementName(), webMethod);
if (conflict != null) {
warn("%s: C# requires that all header parameters defined in the same endpoint interface have unique names. This return parameter conflicts with the one at %s.", positionOf(webMethod), positionOf(conflict));
usesUnmappableElements = true;
}
}
if (webMethod.getWebResult().getType() instanceof MapType) {
warn("%s: C# can't handle return types that are maps.", positionOf(webMethod));
usesUnmappableElements = true;
}
if (ElementUtils.capitalize(webMethod.getClientSimpleName()).equals(ei.getClientSimpleName())) {
warn("%s: C# can't handle methods that are of the same name as their containing class. Either rename the method, or use the @org.codehaus.enunciate.ClientName annotation to rename the method (or type) on the client-side.", positionOf(webMethod));
usesUnmappableElements = true;
}
}
}
}
if (this.jaxbModule != null && this.jaxbModule.getJaxbContext() != null && !this.jaxbModule.getJaxbContext().getSchemas().isEmpty()) {
for (SchemaInfo schemaInfo : this.jaxbModule.getJaxbContext().getSchemas().values()) {
for (TypeDefinition complexType : schemaInfo.getTypeDefinitions()) {
for (Attribute attribute : complexType.getAttributes()) {
if (ElementUtils.capitalize(attribute.getClientSimpleName()).equals(complexType.getClientSimpleName())) {
warn("%s: C# can't handle properties/fields that are of the same name as their containing class. Either rename the property/field, or use the @com.webcohesion.enunciate.metadata.ClientName annotation to rename the property/field on the client-side.", positionOf(attribute));
usesUnmappableElements = true;
}
}
if (complexType.getValue() != null) {
if (ElementUtils.capitalize(complexType.getValue().getClientSimpleName()).equals(complexType.getClientSimpleName())) {
warn("%s: C# can't handle properties/fields that are of the same name as their containing class. Either rename the property/field, or use the @com.webcohesion.enunciate.metadata.ClientName annotation to rename the property/field on the client-side.", positionOf(complexType.getValue()));
usesUnmappableElements = true;
}
}
for (Element element : complexType.getElements()) {
if (ElementUtils.capitalize(element.getClientSimpleName()).equals(complexType.getClientSimpleName())) {
warn("%s: C# can't handle properties/fields that are of the same name as their containing class. Either rename the property/field, or use the @com.webcohesion.enunciate.metadata.ClientName annotation to rename the property/field on the client-side.", positionOf(element));
usesUnmappableElements = true;
}
if (element.getAccessorType() instanceof MapType && !element.isAdapted()) {
warn("%s: The C# client doesn't have a built-in way of serializing a Map. Use @XmlJavaTypeAdapter to supply your own adapter for the Map.", positionOf(element));
usesUnmappableElements = true;
}
}
if (complexType instanceof EnumTypeDefinition) {
List<VariableElement> enums = complexType.enumValues();
for (VariableElement enumItem : enums) {
if (isIgnored(enumItem)) {
continue;
}
String simpleName = enumItem.getSimpleName().toString();
ClientName clientNameInfo = enumItem.getAnnotation(ClientName.class);
if (clientNameInfo != null) {
simpleName = clientNameInfo.value();
}
if ("event".equals(simpleName)) {
warn("%s: C# can't handle an enum constant named 'Event'. Either rename the enum constant, or use the @com.webcohesion.enunciate.metadata.ClientName annotation to rename it on the client-side.", positionOf(enumItem));
usesUnmappableElements = true;
} else if (simpleName.equals(complexType.getClientSimpleName())) {
warn("C# can't handle properties/fields that are of the same name as their containing class. Either rename the property/field, or use the @com.webcohesion.enunciate.metadata.ClientName annotation to rename the property/field on the client-side.", positionOf(enumItem));
usesUnmappableElements = true;
}
}
}
if (ElementUtils.isMap(complexType)) {
warn("%s: C# client doesn't handles types that implement java.util.Map. Use @XmlJavaTypeAdapter to supply your own adapter for the Map.", positionOf(complexType));
usesUnmappableElements = true;
}
}
}
}
return usesUnmappableElements;
}
use of com.webcohesion.enunciate.modules.jaxws.model.EndpointInterface in project enunciate by stoicflame.
the class WsdlInfo method getImportedNamespaces.
/**
* Get the imported namespaces used by this WSDL.
*
* @return The imported namespaces used by this WSDL.
*/
public Set<String> getImportedNamespaces() {
Set<EndpointInterface> endpointInterfaces = getEndpointInterfaces();
if ((endpointInterfaces == null) || (endpointInterfaces.size() == 0)) {
throw new IllegalStateException("WSDL for " + getTargetNamespace() + " has no endpoint interfaces!");
}
HashSet<String> importedNamespaces = new HashSet<String>();
// always import the list of known namespaces.
importedNamespaces.add("http://schemas.xmlsoap.org/wsdl/");
importedNamespaces.add("http://schemas.xmlsoap.org/wsdl/http/");
importedNamespaces.add("http://schemas.xmlsoap.org/wsdl/mime/");
importedNamespaces.add("http://schemas.xmlsoap.org/wsdl/soap/");
importedNamespaces.add("http://schemas.xmlsoap.org/wsdl/soap12/");
importedNamespaces.add("http://schemas.xmlsoap.org/soap/encoding/");
importedNamespaces.add("http://www.w3.org/2001/XMLSchema");
for (EndpointInterface endpointInterface : endpointInterfaces) {
importedNamespaces.addAll(endpointInterface.getReferencedNamespaces());
}
if (isInlineSchema()) {
SchemaInfo associatedSchema = getAssociatedSchema();
if (associatedSchema != null) {
importedNamespaces.addAll(associatedSchema.getReferencedNamespaces());
}
}
return importedNamespaces;
}
use of com.webcohesion.enunciate.modules.jaxws.model.EndpointInterface in project enunciate by stoicflame.
the class ServiceGroupImpl method getServices.
@Override
public List<? extends Service> getServices() {
ArrayList<Service> services = new ArrayList<Service>();
FacetFilter facetFilter = this.registrationContext.getFacetFilter();
for (EndpointInterface endpointInterface : this.wsdlInfo.getEndpointInterfaces()) {
if (!facetFilter.accept(endpointInterface)) {
continue;
}
services.add(new ServiceImpl(endpointInterface, "", registrationContext));
}
Collections.sort(services, new Comparator<Service>() {
@Override
public int compare(Service o1, Service o2) {
return o1.getLabel().compareTo(o2.getLabel());
}
});
return services;
}
Aggregations