Joke Collection Website - Public benefit messages - Java language uses post to call webService.
Java language uses post to call webService.
Import? Java . io . buffered reader;
Import? Java . io . io exception;
Import? Java . io . inputstream;
Import? Java . io . inputstreamreader;
Import? Java . io . output stream;
Import? Java . io . output streamwriter;
Import? Java . net . URL;
Import? Java . net . URL connection;
Import? Java . net . URL encoder;
Import? org . Apache . cxf . endpoint . client;
Import? org . Apache . cxf . jaxws . endpoint . dynamic . jaxwsdynamicclientfactory;
/**
*? Function description: WebService call
*?
*/
Public? Class? ClientTest? {
/**
*? Function description: HTTP-POST
*?
*/
Public? String? post()? {
OutputStreamWriter? Out? =? null
StringBuilder? sTotalString? =? New? StringBuilder();
Try it? {
Website? urlTemp? =? New? Website (
"/web services/weather web service . asmx/getSupportCity ");
URLConnection? Contact? =? URL temp . open connection();
connection . setdoooutput(true);
Out? =? New? output streamwriter(connection . get output stream(),? “UTF-8”);
StringBuffer? sb? =? New? string buffer();
Sb.append("byProvinceName= Fujian ");
out . write(sb . tostring());
out . flush();
String? sCurrentLine
sCurrentLine? =? "";
InputStream? l _ urlStream
l_urlStream? =? connection . getinputstream(); //? request
BufferedReader? l_reader? =? New? BufferedReader (new? Input stream reader (
l _ urlStream));
What time? ((sCurrentLine? =? l_reader.readLine())? ! =? null)? {
stotalstring . append(sCurrentLine);
}
}? Catch? (exception? e)? {
e . printstacktrace();
}? Finally? {
What if? (null? ! =? Out)? {
Try it? {
out . close();
}? Catch? (IOException? e)? {
e . printstacktrace();
}
}
}
Return? stotalstring . tostring();
}
}
- Related articles
- Rice noodle card, daily rental flow in 3 yuan, unlimited flow. Do you have to use Xiaomi? Is there a monthly rent?
- Xinhua Life Insurance Deduction Prompt Information.
- Does Meizu Charm Blue Max rear camera use Sony sensor?
- How to brush diamonds in Taobao? How to brush diamonds in Taobao shop?
- How to use dual-player on Honor Play 8c
- Writing a thank you letter after an interview with a state-owned enterprise
- Which operator provided the SMS number118114?
- China Construction Bank 30 yuan SMS Deduction Fee Refund
- In "Slaying the Wolf 2", are you excited to watch Wu Jing's solo adventure to save the masses?
- My boyfriend's father died. How can I comfort him?