com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

Endpoints with Governance API

Note

Please follow the documentation on how to create a client-side connection to use the Governance API before following these examples.

Endpoint and EndpointManager (similar to the services, WSDLs, schemas, and policies) can be used to add, update, and remove endpoints and associate them with other Governance Artifact products.

Unlike all the above mentioned governance artifacts, Endpoint does not provide EndpointFilter or findEndpoints methods on discovering Endpoints.

Rather, you can get a reference to the Endpoint object directly using the getEndpointByUrl method in EndpointManager class.

import org.wso2.carbon.governance.api.endpoints.EndpointManager;
import org.wso2.carbon.governance.api.endpoints.dataobjects.Endpoint;

EndpointManager endpointManager = new EndpointManager(registry);
Endpoint endpoint1 = endpointManager.getEndpointByUrl("http://localhost/papapa/booom");

Adding an Endpoint Resource 

An Endpoint can be added to the registry by creating a new endpoint and using the method addEndpoint of EndpointManager.

Endpoint endpoint2 = endpointManager.newEndpoint("http://localhost/test/justEndpoint");
endpointManager.addEndpoint(endpoint2);

Adding a Service with Endpoints 

Endpoints can be defined for Services by adding the Endpoint as an attribute with the key endpoints_entry.The value of the attribute should contain Environment name and the Endpoint URL and should be in the format <Environment>:<Endpoint URL> .

Service service = serviceManager.newService(new QName("http://wso2.com/test/mys1", "myService"));
service.addAttribute("endpoints_entry", "Dev:http://endpoint1");
service.addAttribute("endpoints_entry", "QA:jms:/endpoint2");
serviceManager.addService(service);
 

Attaching an Endpoint to a Service

An already existing Endpoint can be attached to an existing Service or a WSDL by using the method attachEndpoint of the artifact. It is always necessary to update the Service or the WSDL after attaching the Endpoint. The given below example is for Services and similar operations can be done on WSDLs as well.

//Creating the Service
Service service = serviceManager.newService(new QName("http://wso2.com/test/mys1", "myService"));
serviceManager.addService(service);
 
//Creating the Endpoint
Endpoint ep1 = endpointManager.newEndpoint("https://localhost:9443/axis2/services/TestEndpointToService");
endpointManager.addEndpoint(ep1);


//Attaching the Endpoint            
service.attachEndpoint(ep1);


//Update the Service            
serviceManager.updateService(service);

Detaching an Endpoint from a Service

An Endpoint already attached to a Service or WSDL can also be Detached from the resource. Detaching operation would remove the Endpoint resource from the registry. And it is necessary to update the Service after detaching the Endpoint. The given below example is for Services and similar operations can be done on WSDLs as well.

service.detachEndpoint(ep1.getId());
serviceManager.updateService(service);

Note : Detaching an Endpoint which is defined in a WSDL would delete the Endpoint resource but that removal would not get effected on the WSDL, Therefor once the WSDL resource is updated that removed Endpoint would added back to the registry. Therefor if it is necessary to do an endpoint change for a WSDL the best practice would be to format the WSDL as required.

Get Attached Endpoints 

The attached Endpoints to a Service or WSDL can be retrieved by using the getAttachedEndpoints method of the artifact. The given below example is for WSDLs and similar operations can be done on Services as well.

Wsdl wsdl = wsdlManager.newWsdl("http://people.wso2.com/~test/wsdls/echo.wsdl");
wsdlManager.addWsdl(wsdl);
Endpoint[] endpoints = wsdl.getAttachedEndpoints();
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.