Accessing WSO2 ESB proxy in java program

左心房为你撑大大i 提交于 2019-12-24 16:33:16

问题


I have configured one wsdl proxy for external wsdl in WSO2 esb. Its successfully created proxy. While creating proxy, I have not selected Publish Same Service Contract check box. If we are consuming external web services, is it mandatory to check? When I click on try it, it is not showing operations which are available in wsdl.

If at all the above issues gets solved, we need to access the proxy from our java project. How can we access WSO2 ESB proxy in our java program?

Thanks in advance.

Thanks, Raghu


回答1:


Yes you need to check Publish Same Service Contract if you want to publish the same WSDL.

in java code you can write a simple axis2 client like shown below. To the enxpoint of your proxy.

   public OMElement sendReceive(OMElement payload, String endPointReference, String operation)
            throws AxisFault {
        ServiceClient sender;
        Options options;
        OMElement response = null;

        try {
            sender = new ServiceClient();
            options = new Options();
            options.setTo(new EndpointReference(endPointReference));
            options.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
            options.setTimeOutInMilliSeconds(45000);
            options.setAction("urn:" + operation);
            sender.setOptions(options);

            response = sender.sendReceive(payload);

        } catch (AxisFault axisFault) {
            throw new AxisFault("AxisFault while getting response :" + axisFault.getMessage(), axisFault);
        }
        Assert.assertNotNull(response);
        return response;
    }

You can get the sample payload by tying a tool like soap UI.

Thank You, Dharshana.




回答2:


Try like this:

    CentralUuidService service = new CentralUuidService(new URL("http://wls02.tigeritbd.com:8280/services/CentralUuidService?wsdl"),new QName("http://bean.service.uuid.gov.bd/", "CentralUuidService"));

    GetBirthPlaceServiceResponse response = service.getCentralUuidServiceHttpSoap11Endpoint().getBirthPlace(request);        
    if(response != null) {
        System.out.println("Operation status is:"+response.isOperationStatus());
    }
}


来源:https://stackoverflow.com/questions/15434170/accessing-wso2-esb-proxy-in-java-program

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!