内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

webservice調(diào)用-創(chuàng)新互聯(lián)

第一種辦法:下載apache cxf的包,使用wsdl2java工具生成java客戶端,未能解決帶驗證的問題。

創(chuàng)新互聯(lián)公司是一家專業(yè)提供湘潭企業(yè)網(wǎng)站建設(shè),專注與做網(wǎng)站、成都做網(wǎng)站、H5高端網(wǎng)站建設(shè)、小程序制作等業(yè)務(wù)。10年已為湘潭眾多企業(yè)、政府機構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站設(shè)計公司優(yōu)惠進行中。

第二種方法:根據(jù)wsdl文件生成客戶端,也沒找到解決方法。

最后使用httpclient解決。

public class DynamicHttpclientCall {

  private String namespace;

  private String methodName;

  private String wsdlLocation;

  private String soapResponseData;

private String username;

private String password;

private String myWorkStation;

static int socketTimeout = 30000;// 請求超時時間

  static int connectTimeout = 30000;// 傳輸超時時間

  public DynamicHttpclientCall(String namespace, String methodName,

    String wsdlLocation,String username,String password,String myWorkStation) {

    this.namespace = namespace;

    this.methodName = methodName;

    this.wsdlLocation = wsdlLocation;

    this.username = username;

    this.password = password;

    this.myWorkStation = myWorkStation;

  }

  public HttpClientContext createBasicAuthContext(HttpHost host,String username, String password) {

    CredentialsProvider credsProvider = new BasicCredentialsProvider();

    Credentials defaultCreds = new UsernamePasswordCredentials(username, password);

    credsProvider.setCredentials(new AuthScope(host.getHostName(), host.getPort()), defaultCreds);

    AuthCache authCache = new BasicAuthCache();

    BasicScheme basicAuth = new BasicScheme();

    authCache.put(host, basicAuth);

    HttpClientContext context = HttpClientContext.create();

    context.setCredentialsProvider(credsProvider);

    context.setAuthCache(authCache);

    return context;

  }

  public String invoke(Map<String, String> patameterMap) throws Exception {

   //HttpHost host = new HttpHost("piprd.shandongair.com.cn",50000);

   //HttpClientContext createBasicAuthContext = createBasicAuthContext(host,username,password);

   HttpPost postMethod = new HttpPost(wsdlLocation);

   postMethod.setHeader("Content-type", "application/soap+xml; charset=utf-8");

//    HttpRequest postMethod = new HttpRequest(wsdlLocation);

    String soapRequestData = buildRequestData(patameterMap);

//     byte[] bytes = soapRequestData.getBytes("utf-8");

//     InputStream inputStream = new ByteArrayInputStream(bytes, 0,bytes.length);

//     RequestEntity requestEntity = new InputStreamRequestEntity(inputStream, bytes.length, "application/soap+xml; charset=utf-8");

//     postMethod.setRequestEntity(requestEntity);

    postMethod.setEntity(new StringEntity(soapRequestData));

    HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();

//    // 設(shè)置BasicAuth

    CredentialsProvider provider = new BasicCredentialsProvider();

//    // Create the authentication scope

    AuthScope scope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM);

//    // Create credential pair,在此處填寫用戶名和密碼

    UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);

//    // Inject the credentials

    provider.setCredentials(scope, credentials);

//    // Set the default credentials provider

    httpClientBuilder.setDefaultCredentialsProvider(provider);

//    // HttpClient

    CloseableHttpClient closeableHttpClient = httpClientBuilder.build();

//     httpClient.getParams().setParameter(HttpProtocolParams.HTTP_CONTENT_CHARSET, "utf-8");

//     NTCredentials creds = new NTCredentials(username,password,myWorkStation,"");

    CloseableHttpResponse execute = closeableHttpClient.execute(postMethod);

    int statusCode = execute.getStatusLine().getStatusCode();

    String text = IOUtils.toString(execute.getEntity().getContent(), "utf-8");

    return text;

  }

//   public int invoke(Map<String, String> patameterMap) throws Exception {

//     PostMethod postMethod = new PostMethod(wsdlLocation);

//     String soapRequestData = buildRequestData(patameterMap);

//

//     byte[] bytes = soapRequestData.getBytes("utf-8");

//     InputStream inputStream = new ByteArrayInputStream(bytes, 0,bytes.length);

//     RequestEntity requestEntity = new InputStreamRequestEntity(inputStream, bytes.length, "application/soap+xml; charset=utf-8");

//     postMethod.setRequestEntity(requestEntity);

//

////     HttpClient httpClient = new HttpClient();

//     // 創(chuàng)建HttpClientBuilder

//     HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();

////     // 設(shè)置BasicAuth

//     CredentialsProvider provider = new BasicCredentialsProvider();

////     // Create the authentication scope

//     AuthScope scope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM);

////     // Create credential pair,在此處填寫用戶名和密碼

//     UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);

////     // Inject the credentials

//     provider.setCredentials(scope, credentials);

////     // Set the default credentials provider

//     httpClientBuilder.setDefaultCredentialsProvider(provider);

////     // HttpClient

//     CloseableHttpClient closeableHttpClient = httpClientBuilder.build();

//

////     httpClient.getParams().setParameter(HttpProtocolParams.HTTP_CONTENT_CHARSET, "utf-8");

////     NTCredentials creds = new NTCredentials(username,password,myWorkStation,"");

//

//

//

//     int statusCode = httpClient.executeMethod(postMethod);

//     soapResponseData = postMethod.getResponseBodyAsString();

//     return statusCode;

//   }

  private String buildRequestData(Map<String, String> patameterMap) {

    StringBuffer soapRequestData = new StringBuffer();

    soapRequestData.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:com=\"com:sda:querydata\"><soapenv:Header/>");

    soapRequestData.append("<soapenv:Body><com:MT_DD_Request><MSGRP></MSGRP></com:MT_DD_Request></soapenv:Body></soapenv:Envelope>");

//     Set<String> nameSet = patameterMap.keySet();

//     for (String name : nameSet) {

//       soapRequestData.append("<" + name + ">" + patameterMap.get(name)+ "</" + name + ">");

//     }

    return soapRequestData.toString();

  }

}



另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

當(dāng)前文章:webservice調(diào)用-創(chuàng)新互聯(lián)
當(dāng)前網(wǎng)址:http://www.rwnh.cn/article48/ccjohp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計、網(wǎng)頁設(shè)計公司、Google、電子商務(wù)、網(wǎng)站制作、用戶體驗

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管
曲阳县| 北川| 陵川县| 永城市| 巧家县| 土默特左旗| 唐河县| 宁蒗| 孝感市| 鄄城县| 凯里市| 阜宁县| 耒阳市| 金溪县| 施甸县| 宿迁市| 迁安市| 大港区| 银川市| 茂名市| 海丰县| 大英县| 防城港市| 蒙阴县| 丹寨县| 双峰县| 宁都县| 龙井市| 三江| 阜新| 贡觉县| 苗栗市| 鲁甸县| 上杭县| 柳州市| 万盛区| 东明县| 八宿县| 灌云县| 法库县| 白城市|