2017-07-04 2 views
0

i un service Web C#, il est très simple,simple C# Web Service travaille localement, mais pas sur le serveur

j'ai référence web qui utilise un WSDL externe,

travaille localement sur la machine de l'entreprise, mais pas sur un serveur de l'entreprise.

J'ai vu sur d'autres messages ceci pourrait être lié par proxy, mais j'ai fatigué quelques édits différents au webconfig concernant le proxy, mais j'ai besoin de l'aide des experts.

Lorsque j'appelle invoke lorsque le service Web est en cours d'exécution sur le serveur via le navigateur, j'obtiens l'erreur "Impossible de se connecter au serveur distant".

<?xml version="1.0" encoding="utf-8" ?> 
<string xmlns="http://www.service-now.com/CatalogUpdateAutomationVariables">Unable to connect to the remote server</string> 

WEB CONFIG

<?xml version="1.0"?> 
<!-- 
    For more information on how to configure your ASP.NET application, please visit 
    http://go.microsoft.com/fwlink/?LinkId=169433 
    --> 
<configuration> 
    <configSections> 
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
     <section name="InboundServiceNowWeb.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/> 
    </sectionGroup> 
    </configSections> 
    <system.web> 
    <compilation targetFramework="4.5.2" debug="true"/> 
    <httpRuntime targetFramework="4.5.2"/> 
    <customErrors mode="Off"/> 
    <webServices> 
     <protocols> 
     <add name="HttpGet"/> 
     <add name="HttpPost"/> 
     </protocols> 
    </webServices> 
    </system.web> 
    <system.codedom> 
    <compilers> 
     <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/> 
     <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/> 
    </compilers> 
    </system.codedom> 
    <system.serviceModel> 
    <bindings/> 
    <client/> 
    </system.serviceModel> 
    <applicationSettings> 
    <InboundServiceNowWeb.Properties.Settings> 
     <setting name="InboundServiceNowWeb_ServiceNowDev_ServiceNow_CatalogUpdateAutomationVariables" serializeAs="String"> 
     <value>https://COMPANY.service-now.com/CatalogUpdateAutomationVariables.do?SOAP</value> 
     </setting> 
    </InboundServiceNowWeb.Properties.Settings> 
    </applicationSettings> 
    <system.net> 
    <defaultProxy enabled="true" useDefaultCredentials="false" /> 
    </system.net> 
</configuration> 
<!--ProjectGuid: {55A9796B-1C01-4454-B0C3-942C1C8221B5}--> 

C#

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Services; 

namespace InboundServiceNowWeb 
{ 
    /// <summary> 
    /// Summary description for ServiceNowInboundSOAP 
    /// </summary> 
    [WebService(Namespace = "http://www.service-now.com/CatalogUpdateAutomationVariables")] 
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 
    [System.ComponentModel.ToolboxItem(false)] 
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService] 
    public class ServiceNowInboundSOAP : System.Web.Services.WebService 
    { 

     [WebMethod] 
     public string UpdateCatalogRITM(string RITM, string ReturnCode, string ReturnMessage, string Comment) 
     { 
      // return "Hello World1"; 
      /* 
      //SERVICE REFERENCE-SPECIFIC CODE 
      ServiceNowDev.ServiceNowSoapClient soapClient = new ServiceNowDev.ServiceNowSoapClient(); 
      soapClient.ClientCredentials.UserName.UserName = "sys_ws_catalog"; 
      soapClient.ClientCredentials.UserName.Password = "#####"; 

      ServiceNowDev.update insert = new InboundServiceNowWeb.ServiceNowDev.update(); 
      //ServiceNowDEV.update response = new ServiceNowDEV.updateResponse(); 
      ServiceNowDev.updateResponse response = new InboundServiceNowWeb.ServiceNowDev.updateResponse(); 
      */ 
      // WEB REFERENCE-SPECIFIC CODE 
      ServiceNowDev.ServiceNow_CatalogUpdateAutomationVariables soapClient = new InboundServiceNowWeb.ServiceNowDev.ServiceNow_CatalogUpdateAutomationVariables(); 
      System.Net.ICredentials cred = new System.Net.NetworkCredential("sys_ws_catalog", "catalog01"); 
      soapClient.Credentials = cred; 

      ServiceNowDev.update insert = new ServiceNowDev.update(); 
      ServiceNowDev.updateResponse response = new ServiceNowDev.updateResponse(); 
      // END OF WEB REFERENCE CODE */ 

      insert.RequestNumber = RITM; 
      insert.ReturnCode = ReturnCode; 
      insert.ReturnMessage = ReturnMessage; 
      insert.Comments = Comment; 

      try 
      { 
       response = soapClient.update(insert); 
       return response.result; 

      } 
      catch (Exception error) 
      { 
       return error.Message; 
       // this.Response.Text = error.Message; 
      } 
     } 
    } 
} 
+0

« Je reçois l'erreur « Impossible de se connecter au serveur distant » » - * où * en êtes-vous cette erreur? Voulez-vous dire que votre navigateur ne peut pas s'y connecter ou ne peut-il pas se connecter à autre chose? Avez-vous eu d'autres applications Web fonctionnant sur le même serveur? Il y a tout simplement trop peu d'informations pour que nous puissions continuer pour le moment ... –

+0

Ouais je reçois l'erreur sur le serveur quand je la lance dans le navigateur –

+0

Désolé, ce n'est pas plus clair. "obtenir l'erreur sur le serveur" est loin d'être précis. S'il vous plaît * éditez votre question * pour être très, très clair sur ce que vous voyez. –

Répondre

0

Après quelques modifications au pare-feu de l'entreprise pour les serveurs i a pu se connecter avec succès.

Merci pour votre aide