工作之餘抽點時間出來寫寫博文,希望對新接觸的朋友有幫助。今天在這裡和大家一起學習一下物件伺服器
// 定義web service的命名空間
static final string service_ns = "";
// 定義web service供給務服的url
static final string service_url = "";
* 獲得省的列表
* @return
public static listgetprovincelist() {
// 用調的法方
final string methodname = "getregionprovince";
// 建創httptransportse傳輸物件
// 應用soap1.1議協建創envelop物件
final soapserializationenvelope envelope =
new soapserializationenvelope(soapenvelope.ver11);
// 例項化soapobject物件
soapobject soapobject = new soapobject(service_ns, methodname);
envelope.bodyout = soapobject;
// 設定與.net供給的web service持保較好的相容性
envelope.dotnet = true;
futuretask> task = new futuretask>(
new callable>(){
@override
public listcall()throws exception{
// 用調web service
ht.call(service_ns + methodname, envelope);
if (envelope.getresponse() != null){
// 獲得務服器響應返回的soap訊息
soapobject result = (soapobject) envelope.bodyin;
soapobject detail = (soapobject) result.getproperty(
methodname + "result");
// 析解務服器響應的soap訊息。
return parseprovinceorcity(detail);
return null;
new thread(task).start();
try{
return task.get();
catch (exception e){
e.printstacktrace();
return null;
* 根據省獲得市列表
* @param province
* @return
public static listgetcitylistbyprovince(string province) {
// 用調的法方
final string methodname = "getsupportcitystring";
// 建創httptransportse傳輸物件
// 例項化soapobject物件
soapobject soapobject = new soapobject(service_ns, methodname);
// 新增乙個請求引數
soapobject.addproperty("theregioncode", province);
// 應用soap1.1議協建創envelop物件
final soapserializationenvelope envelope =
每日一道理
成功的花朵開放在啊勤勞的枝頭,失敗的苦果孕育在懶惰的溫床之中。
new soapserializationenvelope(soapenvelope.ver11);
envelope.bodyout = soapobject;
// 設定與.net供給的web service持保較好的相容性
envelope.dotnet = true;
futuretask> task = new futuretask>(
new callable>(){
@override
public listcall()
throws exception
// 用調web service
ht.call(service_ns + methodname, envelope);
if (envelope.getresponse() != null)
// 獲得務服器響應返回的soap訊息
soapobject result = (soapobject) envelope.bodyin;
soapobject detail = (soapobject) result.getproperty(
methodname + "result");
// 析解務服器響應的soap訊息。
return parseprovinceorcity(detail);
return null;
new thread(task).start();
tryreturn task.get();
catch (exception e)
e.printstacktrace();
return null;
* 獲得氣天
* @param cityname
* @return
public static soapobject getweatherbycity(string cityname){
final string methodname = "getweather";
final soapserializationenvelope envelope =
new soapserializationenvelope(soapenvelope.ver11);
soapobject soapobject = new soapobject(service_ns, methodname);
soapobject.addproperty("thecitycode", cityname);
envelope.bodyout = soapobject;
// 設定與.net供給的web service持保較好的相容性
envelope.dotnet = true;
futuretasktask = new futuretask(
new callable(){
@override
public soapobject call()throws exception{
ht.call(service_ns + methodname, envelope);
soapobject result = (soapobject) envelope.bodyin;
soapobject detail = (soapobject) result.getproperty(
methodname + "result");
return detail;
new thread(task).start();
try{
return task.get();
catch (exception e){
e.printstacktrace();
return null;
private static listparseprovinceorcity(soapobject detail){
arraylistresult = new arraylist();
for (int i = 0; i < detail.getpropertycount(); i++){
// 析解出每乙個省分
result.add(detail.getproperty(i).tostring().split(",")[0]);
return result;
webservice伺服器端發票識別API介面
發票,乙個再也熟悉不過的財務往來憑證,錄入發票,一項讓多少財會人員頭疼的工作。過去錄入一張發票需要乙個財會人員5分鐘的時間,那麼這個人在工作8小時內也只能審核100張左右的發票。以前,沒技術,沒平台,單靠人工來做這些重複性較大的工作,著實痛苦。自從有了ocr人工智慧,這些頭疼的事情,也成為了歷史。私...
HTTP伺服器 物件導向
import socket import gevent import time from gevent import monkey class webserver object 把http伺服器的功能都封裝在webserver類中 documents root html 這裡配置伺服器,配置服務端的...
automation伺服器不能建立物件
網頁上開啟本地客戶端程式 整體思路在前面的文章已經有介紹,專案實際使用過程中遇到乙個問題,建立activexobject物件時,提示automation伺服器不能建立物件錯誤。就這個錯誤搞了兩天,之前一直是可以的,突然不可以,很是糾結呀,現在把該問題的原因及解決方法告訴大家,當然該問題的發生可能有多...