开发者

Writing Webservice clients using HttpURLConnection

I have a question related to Axis2 Webservices . I have My Webservice deployed in Tomcat Server .

Right now i am writing a Client for my Webservice using

public static void main(String[] args) {
    try {
        samples.quickstart.StockQuoteServiceStub stub = new samples.quickstart.StockQuoteServiceStub();
        samples.quickstart.StockQuoteServiceStub.GetPrice request = new samples.quickstart.StockQuoteServiceStub.GetPrice();
        request.setSymbol("ABCDE");
        samples.quickstart.StockQuoteServiceStub.GetPriceResponse response = stub
        .getPrice(request);
    }
    catch (org.apache.axis2.AxisFault e) {
        e.printStackTrace();
        } catch (java.rmi.RemoteException e) {
        e.printStackTrace();
    }
}

This works fine.

I have seen from net some clients are written using HttpURLConnection.

Please tell me what is the differe开发者_如何学编程nce between writing clients by using the former way and the later way.


The way you have done give you a more abstract way. It has generated the code for you and you need only to provide the parameters to pass. Here Axis2 users the commons httpclient as to send message using http transport. As you can see Axis2 handles all the transport specific things for you.

On the other hand you can create the soap message to send from your own and send using an httpClient. But there you need to do a lot of work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜