2016-09-18 39 views
0

逗人, 我從客戶端以下Web服務調用: http://ajec.proxym-it.net/Ajec_sso_api/authenticate.wsdl調用Web服務錯誤「遠程服務器返回了意外的響應:(502)連接被拒絕。」

當我嘗試使用它,我得到了這個錯誤: 遠程服務器返回了意外的響應:(502)連接被拒絕。

內部異常是:{ 「遠程服務器返回一個錯誤:(502)錯誤的網關。」}

這是我的代碼:

AuthenticateService.AuthenticatePortClient oAuthenticatePortClient = new AuthenticateService.AuthenticatePortClient(); 
AuthenticateService.authenticateRequest oauthenticateRequest = new AuthenticateService.authenticateRequest(); 

oauthenticateRequest.serviceId = "MobileTeam"; 
oauthenticateRequest.serviceKey = "AJEC1"; 
oauthenticateRequest.userName = "MMelhem"; 
oauthenticateRequest.password = "[email protected]$$w0rd"; 

AuthenticateService.authenticateResponse oregisterUserResponse = oAuthenticatePortClient.authenticate(oauthenticateRequest); 

和在web.config是:

<configuration> 
<system.net> 
<defaultProxy> 
<proxy usesystemdefault="False" bypassonlocal="False" /> 
</defaultProxy> 
</system.net> 
<system.web> 
<compilation debug="true" targetFramework="4.5" /> 
<httpRuntime targetFramework="4.5" /> 
</system.web> 

<system.serviceModel> 
<bindings> 
<basicHttpBinding> 
<binding name="AuthenticatePortSoap11" /> 
</basicHttpBinding> 
</bindings> 
<client> 
<endpoint address="http://172.16.0.82:80/Ajec_sso_api/authenticate" 
binding="basicHttpBinding" bindingConfiguration="AuthenticatePortSoap11" 
contract="AuthenticateService.AuthenticatePort" name="AuthenticatePortSoap11" /> 
</client> 
</system.serviceModel> 
</configuration> 
+0

問題一直這項服務曾經爲任何人工作?這是第一次將它作爲web服務使用嗎?它現在對別人有用嗎? HTTP 502意味着壞的網關(後端服務器出現問題)。下一步將是檢查(與管理web服務的人)後端的狀態(除了用戶名/密碼是否正確)。 – blackpen

+0

當試圖在SoupUI應用程序上測試它時,它會工作,但當試圖在代碼上使用它時,它不會。 –

回答

0

你用什麼工具生成客戶端代碼(或手寫代碼)?

我使用了wsimport,我的代碼與你的代碼略有不同。由於IP似乎在本地域(172.16.0.82),我無法測試它。如果你有興趣,你可以試試。

我以前的wsimport生成/編譯客戶端類文件:

wsimport -keep http://ajec.proxym-it.net/Ajec_sso_api/authenticate.wsdl 

然後編碼在客戶端這樣的:

import com.ajec_sso.authenticate.*;  
public class TClient { 
    static AuthenticatePortService service = new AuthenticatePortService(); 
    public static void main(String[] args) {  
     try { 
      AuthenticatePort port = service.getAuthenticatePortSoap11();  
      AuthenticateRequest req = new AuthenticateRequest(); 
      AuthenticateResponse res = new AuthenticateResponse();  
      req.setServiceId("MobileTeam"); 
      req.setServiceKey("AJEC1"); 
      req.setUserName("MMelhem"); 
      req.setPassword("[email protected]$$w0rd");  
      res = port.authenticate(req); 
     } catch(Exception e) { 
      e.printStackTrace(); 
     } 
    } 
} 

編譯這樣的(所生成的com目錄是在當前目錄)。

javac TClient.java 
相關問題