WildFly management - list/detect REST endpoints deployed in WildFly - rest

Is there a way (e.g. from a WildFly management console) to list all REST endpoints deployed in WildFly? Or to list them in a log while a server is starting?

Using the RegistryStatsResource
With RESTEasy (that is shipped with WildFly), you could add the following to your web.xml:
<context-param>
<param-name>resteasy.resources</param-name>
<param-value>org.jboss.resteasy.plugins.stats.RegistryStatsResource</param-value>
</context-param>
And then request the following URL:
http://[hostname]:[port]/[context]/[api-path]/resteasy/registry
Such endpoint can produce XML and JSON content. Just add the Accept header to the request with the desired media type:
application/xml
application/json
Checking the source code
If you are interested in the source code to create your own implementation, have a look at the RegistryStatsResource class on GitHub.
The most relevant part of the source code is shown below (it's RESTEasy specific):
ResourceMethodRegistry registry = (ResourceMethodRegistry)
ResteasyProviderFactory.getContextData(Registry.class);
for (String key : registry.getBounded().keySet()){
List<ResourceInvoker> invokers = registry.getBounded().get(key);
for (ResourceInvoker invoker : invokers) {
if (invoker instanceof ResourceMethodInvoker) {
ResourceMethodInvoker rm = (ResourceMethodInvoker) invoker;
// Extract metadata from the ResourceMethodInvoker
}
}
Swagger may be an alternative
Depending on your requirements, you can use Swagger to document your API. It comes with a set of annotations to describe your REST endpoints.
Then use Swagger UI to provide a live documentation for your API.
Note: As of February 2017, looks like the RegistryStatsResource class is completely undocumented. I occasionally discovered it when digging into the RESTEasy source code for debugging purposes. Also, I found this JBoss EAP issue that tracks the lack of documentation for that class.

From the Management Console, you can view the published endpoints.
When you login as an administrator, Click the Runtime option on the top navigation bar as shown below.
Click the JAX-RS option, then click the REST Resources option. This will display the endpoints to the far right.

Related

Apache Camel REST - not connecting

I'm trying to get Apache Camel's REST DSL working but it's not connecting for me.
I've got a RouteBuilder that's being called:
#Override
public void configure() {
restConfiguration().component("servlet")
.contextPath("/")
.enableCORS(true)
.dataFormatProperty("prettyPrint", "true")
.apiContextPath("/api-doc")
.apiProperty("api.version", buildVersion)
.apiProperty("cors", "true")
.bindingMode(RestBindingMode.json);
rest("/say/hello")
.get().route().transform().constant("Hello World");
}
but then the routes don't actually work.
This is inside a Spring Boot app that has other REST endpoints defined via JAX-RS but this is an integration package that I want to be able to keep separate. The weird thing is that this WAS working a few months ago before I had to work on other things, but now, coming back to it, I can't even get this simple endpoint working.
I've got Camel in my Maven pom.xml and everything seems to be starting correctly, but nothing happens when I hit http:://localhost:9071/say/hello, I just get the standard Tomcat 404 page.
Any thoughts on what I'm missing?
According to this: http://www.baeldung.com/apache-camel-spring-boot
As of Camel’s version 2.19, this configuration has been dropped as the
CamelServlet is by default set to “/camel”.
so /camel/say/hello is the correct URL and it works for me. Still looking at how to customize this.
EDIT:
Here's how to customize this under Spring Boot. You add a property to application.properties like this:
camel.component.servlet.mapping.contextPath=/*

WSO2 Carbon 404 Error Redirection for Webapp Deployment?

We are using WSO2 Carbon 4.2.0 through the WSO2 Application Server (AS) package. In replacing an older, highly customized Carbon installation (provided by a company that no longer supports the product, has abandoned it and refuses to work on it, and left us no details on how/what they modified in Carbon), we have deployed a couple web applications in the webapps container as they were deployed before in the older instance. We have changed our WebContextRoot in the carbon.xml from the default "/" to a sub-URL of ex: "/stuff", as is also detailed in the self-answered SO question here. However the answer given there is not detailed in what the OP actually encountered when he modified his WSO2 instance.
In testing the above configuration we noticed that if a user were to go to a non-existent web address on the server, depending on the format of the URL they are either:
redirected to a blank page;
receive a "500 Internal server error" (I suspect this is the embedded Tomcat?);
get sent to the Carbon login page (which we definitely do not want to happen for security reasons); or
get an XML document stating:
<faultString> The service cannot be found for the endpoint reference (EPR) /stuff/services/nonexistantservicename </faultString>
At least in the case of missing content we wish the user to be sent to a standardized 404 error page, or at the least be sent an HTTP 404 error by the server. For services the XML error is palatable, we can deal with that.
The only option for us right now to circumvent this issue is to place a proxy in front of the WSO2 instance, which would be another layer to manage and tune, and possibly degrade performance. Please know that I am not a programmer but just an admin with DevOps experience. I would not know how to handle this with e.g. a Java solution or re-coding parts of WSO2. Customizing the core product would also hamper future upgrades of WSO2, a scenario we are trying to dig ourselves out of now as detailed above. Is there no internal WSO2 mechanism to handle non-existent content? Can we not redirect any errors to a standard canned response page?

Upgrading to Spring cloud 1.0.1 zuul url encoded parameters not working

We use zuul as an gateway to dispatch incoming requests to services.
When we upgraded from 1.0.0, we noticed two issues, one of which we got a workaround to.
The second issue is that in some of the incoming have encoded uris to deal with special characters in the request, e.g. ....rovi//45846 which needs to be changed to rovi%2F%2F45846 in order to pass in.
So for a rest uri like the following POST http://localhost:8902/contentservice/content/subscriptionPackages/624460160/channels/rovi%252F%252F45846
If I make this request directly to the service, it works correctly.
But if I route it through zuul as POST http://localhost:8765/contentservice/content/subscriptionPackages/624460160/channels/rovi%252F%252F45846 then it disappears.
Now if I take the % out it is passed in and treated as an error in the contentservice when I step through the content service front end controller (off course).
What has changed between spring cloud 1.0.0 to 1.0.1 in the zuul functionality to stop this from working. As it definitely was working in 1.0.0.
So the spring cloud team has fixed this in the snapshot releases and you can fixed more detail here
https://github.com/spring-cloud/spring-cloud-netflix/issues/366#issuecomment-106363315

XDS.b testing with SoapUI

I have to implement a simple client to a XDS.b server (SubmitObjectRequest and RetrieveDocumentSetRequest operations), but I'm struggling to get even a simple example of use to work.
I've tried using Mirth Connect's Channel for XDS.b also, but with no use. I even tried to copy its SOAP envelope to use with SoapUI. Didn't work.
I'm using HIEOS deployed on Glassfish as my XDS.b server.
I'm lost and confused. Could anyone give me a guidance on how to make this work?
If the HIEOS is deployed correctly within the Glassfish the service endpoint provides a wsdl definition where the interface is specified. Check the Glassfish for the wsdl of the service.
http://localhost:8080/my-ws/simple?WSDL
Quelle: docs.oracle.com/cd/E18930_01/html/821-2418/gbiyw.html
The list of provided endpoints you can see here:
https://kenai.com/projects/hieos/pages/WebServices
So to retrieve the wsdl you should use for example:
http://localhost:8080/axis2/services/xdsrepositoryb?wsdl
which applies for the ProvideAndRegisterDocumentSet-b transaction of the XDS Repository actor.
You can use the WSDL definition to create a WS request using SOAP UI at first.
SOAP UI creates a request based upon the wsdl definition which can be used to
test a against your XDS repo.
When you know how a SOAP request must be constructed you can try it using Mirth or
create your own client using Apache CXF http://cxf.apache.org/ for example.
Or you use AXIS2 to create a client from the WSDL. Of course does Visual Studio and C# also offer mechanisms to create a WS client directly from a WSDL definition.

WSO2 Class Mediator gives an error

Our team is completely new to the WSO2 tool. We got the basic training on how to add proxy services and were able to do so as well.
Now, we have to add a class in the In Sequence. We tried that using the Class mediator but it was not able to find the class. Then we realized that the jar file needs to be in the components/lib folder. So, its able to load the class now. It proceeds to the out sequence and fault sequence properly. But, in the end, it gives the following exception.
Unable to add proxy service :: Failed to add proxy service: Parse. Check whether the Proxy already exists-Failed to add proxy service: Parse. Check whether the Proxy already exists
So far, we're using the design view to configure it. I surveyed through most of the posts within this forum, and, all are using the source code to configure. Also, the proxy service is not present in the Source View section under Service Bus.
Are we missing any step in the configuration? Do we need to switch to coding method or it is possible this way.
Your explanation is strange. Above mentioned error log can appear at the time of deploying the proxy service. But you say your proxy is going to the out-sequence and fault-sequence. From that what I understand is the proxy is already deployed.
You can check whether a proxy with the same name is there by looking in the ESB_HOME/repository/deployment/server/synapse-config/default/proxy-service folder. If there is a file with name Parse.xml (I think the name of the proxy service is Parse) you can delete it from the file system and then go to the design view and add the proxy again.
It seems there is already a proxy with the name you provided. Go to WSO2 ESB "source view" and check whether there exist a proxy with that name. Source view is available on the left side of the management console.
This artical will take you step by step in writing custom class mediators.
This post may also be relevant for you.