Wso2 ESB 管理服务获取创建代理 Java
1)您好,我正在尝试使用管理服务在 ESB 中创建代理.
1) Hello I am trying to use the admin services to create an Proxy inside the ESB.
所以我暴露了管理服务 (Hidden=false)
So I have exposed the admin services (Hidden=false)
我已经在我的 Java 项目中导入了 WSDl https://localhost:8243/services/ProxyServiceAdmin?wsdl
I have imported the WSDl in my Java project https://localhost:8243/services/ProxyServiceAdmin?wsdl
但我无法锻炼如何调用方法 addProxy
我是否使用了错误的管理服务?请提供使用此方法的示例.
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) 我有一个代理定义为单行字符串,比如
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?
非常感谢您的关注!
编辑我查看了 WSDL ProxyServiceAdmin?wsdl"它说 <wsdl:operation name="addProxy"><http:operation location="addProxy"/><wsdl:input><mime:content type="text/xml" part="参数"/></wsdl:input><wsdl:output><mime:content type="text/xml" part="parameters"/></wsdl:output>
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>
所以它在那里,但为什么我不能调用它?为什么我的代码不能像普通的 Web 服务那样工作?真的,请帮忙.我不明白我做错了什么......
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
推荐答案
你只需要使用org.wso2.carbon.proxyadmin.stub.ProxyServiceAdminStub"通过管理服务来广告代理
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());
需要将代理的 ProxyData 对象生成为 synaps xml
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);
谢谢你,佛法
相关文章