1) Hello I am trying to use the admin services to create an Proxy inside the ESB.
So I have exposed the admin services (Hidden=false)
I have imported the WSDl in my Java project https://localhost:8243/services/ProxyServiceAdmin?wsdl
But I cannot workout how to call the method addProxy
am I using the wrong admin service? Please help with an example of consuming this method.
ProxyServiceAdmin ps = new ProxyServiceAdmin();
ps.addProxy(); //wrong
2) I have a proxy defined as a one-line String, like
String xmlproxy="<?xml version='1.0' encoding='UTF-8'?><proxy xmlns='http://ws.apache.org/ns/synapse' name='MyProxy1' transports='https' startOnLoad='true' trace='disable'> <target inSequence='sequence1'>...."
Is it possible to add this Proxy by calling some method of the admin services?
thanks a lot for your attention!
EDIT I had a look at the WSDL "ProxyServiceAdmin?wsdl" it says <wsdl:operation name="addProxy"><http:operation location="addProxy"/><wsdl:input><mime:content type="text/xml" part="parameters"/></wsdl:input><wsdl:output><mime:content type="text/xml" part="parameters"/></wsdl:output>
so it is there, but why I cannot call it? Why my code does not work as a normal Web Service would? Really, please help. I don't get what i am doing wrong...
ProxyServiceAdmin ps = new ProxyServiceAdmin();
ps.addProxy(); //not recognized as an operation of ProxyServiceAdmin even if it is in the wsdl
You simply have to use "org.wso2.carbon.proxyadmin.stub.ProxyServiceAdminStub" to ad proxy by admin services
Please have a look at following code and comments inline.
String endPoint = *<your backend service url>* +"ProxyServiceAdmin";
proxyServiceAdminStub = new ProxyServiceAdminStub(endPoint);
You have to authenticate your service stub before make any use of it
CarbonUtils.setBasicAccessSecurityHeaders(userName, password,
proxyServiceAdminStub._getServiceClient());
Need to generate ProxyData object of your proxy as synaps xml
String[] transport = {"http", "https"};
ProxyData data = new ProxyData();
data.setName(proxyName);
data.setWsdlURI(*<url to your WSDL>*);
data.setTransports(transport);
data.setStartOnLoad(true);
data.setEndpointXML("<endpoint xmlns=\"http://ws.apache.org/ns/synapse\"><address uri=\"" + serviceEndPoint + "\" /></endpoint>");
data.setEnableSecurity(true);
proxyServiceAdminStub.addProxy(data);
Thank You, Dharshana
please find the sample to create a proxy using admin service here . I added Darshana's code to a complete example.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.