2016-09-18 35 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 
相关问题