WebService Learning with HttpClient Httpcore

Source: Internet
Author: User

A method of using WebService based on HTTP protocol

First of all, we first download a software called SOAPUI (direct Baidu)

Installing this will not have to say more.

Use:

1. Create a SOAP Project

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/7B/57/wKioL1bMCJuzUFJ9AABuwKXcrzw788.png "title=" E{1 "O) {eay7[~2b2yc6uc59.png "alt=" Wkiol1bmcjuzufj9aabuwkxcrzw788.png "/>


Fill in the WSDL

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/7B/57/wKioL1bMCW2RJmPmAADCKiiY9EA284.png "title=" r@82v{ 8ygwg{' qh%3n$d) ob.png "alt=" Wkiol1bmcw2rjmpmaadckiiy9ea284.png "/>

Then some data is parsed out. Find the interface we want to butt, like my docking method.

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7B/58/wKiom1bMCrTyDPGzAAA0fmffrFg849.png "title=" r_~ " Lr0[4w[17n01alj5%1.png "alt=" Wkiom1bmcrtydpgzaaa0fmffrfg849.png "/>

Double-click to open Yes:

<soapenv:envelope xmlns:soapenv= "http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem= "http://tempuri.org/" >

<soapenv:Header/>

<soapenv:Body>

<tem:update_Lianbi_info>

<!--optional:-->

<tem:USERID>?</tem:USERID>

<!--optional:-->

<tem:SN>?</tem:SN>

<!--optional:-->

<tem:OLD_LBSN>?</tem:OLD_LBSN>

<!--optional:-->

<tem:NEW_LBSN>?</tem:NEW_LBSN>

</tem:update_Lianbi_info>

</soapenv:Body>


And

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7B/58/wKiom1bMEOOxc5nBAAA0s9_uqJM411.png "title="%kav " 8ynq@93$4q_ksmzm99.png "alt=" Wkiom1bmeooxc5nbaaa0s9_uqjm411.png "/>

</soapenv:Envelope>



This is what we are going to need.


Java code

public void Sendlianbiwebservice () throws ParseException, IOException {

HttpClient client = Httpclients.createdefault ();

String reqsoapdata = Buildreqsoapdata (libientity); //Here is the stitching SOAP request

HttpPost post = new HttpPost (wsdlurl);// Wsdlurl is the WSDL provided

try {

httpentity re = new stringentity (Reqsoapdata, "UTF-8");

Post.setheader ("content-type", "text/xml;charset=utf-8");

Post.setheader ("accept-encoding", "gzip,deflate");

Post.setheader ("SOAPAction", "Http://tempuri.org/IWarehouse_Business/update_change_Lianbi_info");

Post.setentity (re);

Response = Client.execute (post);//Send Request

Returninfo = entityutils.tostring (Response.getentity ());

Log.info ("Request service returns XML text:" + returninfo);

} catch (Unsupportedencodingexception e) {

Log.error (E.getstacktrace ());

} catch (Clientprotocolexception e) {

Log.error (E.getstacktrace ());

} catch (IOException e) {

Log.error (E.getstacktrace ());

}

}


Described below

This article is from the "7619052" blog, please be sure to keep this source http://7629052.blog.51cto.com/7619052/1744331

WebService Learning with HttpClient Httpcore

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.