2017-12-13 9 views
1

두 개의 asp.net 웹 사이트가 있습니다 (예 : abc 및 pqr). 첫 번째 애플리케이션 'abc'에는 웹 서비스 인 ListingData.asmx가 있고 두 번째 애플리케이션 pqr에는 해당 웹 서비스를 사용하는 웹 페이지가 있습니다. 'abc'응용 프로그램은 https에서 실행되고 'pqr'은 http에서 실행됩니다. 'ABC 사이트'에 ASMX에 대한 코드는 다음과 같습니다비누 오류 또는 https 관련 오류

ws.ListingData o = new ws.ListingData(); 
    ws.ListingAuthHeader h = new ws.ListingAuthHeader(); 
    h.Username = soapHeaderUsername; 
    h.Password = soapHeaderPassword; 
    o.ListingAuthHeaderValue = h; 
    ds = o.GetListingData(countryId, maxListings); 

나는

'서비스 참조 추가'를 통해 웹 서비스 참조를 추가 한 :

public class ListingAuthHeader : SoapHeader 
    { 
     public string Username; 
     public string Password; 
    } 

    public class ListingAuthHeaderValidation 
    { 
    /// <summary> 
    /// Validates the credentials of the soap header. 
    /// </summary>  

    public static bool Validate(ListingAuthHeader soapHeader) 
    { 
     if (soapHeader == null) 
     { 
      throw new NullReferenceException("No soap header was specified."); 
     } 

     if (soapHeader.Username == null) 
     { 
      throw new NullReferenceException("Username was not supplied for authentication in SoapHeader."); 
     } 

     if (soapHeader.Password == null) 
     { 
      throw new NullReferenceException("Password was not supplied for authentication in SoapHeader."); 
     } 

     if (soapHeader.Username != "a" || soapHeader.Password != "b") 
     { 
      throw new Exception("Please pass the proper username and password for this service."); 
     } 

     return true; 
     } 
    } 

    [WebService(Namespace = "http://tempuri.org/")] 
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 

    public class ListingData : System.Web.Services.WebService { 


    public ListingAuthHeader CustomSoapHeader; 

    [WebMethod] 
    [SoapHeader("CustomSoapHeader")] 

    public DataSet GetListingData(string countryId, int maxListings) 
    { 
    ListingAuthHeaderValidation.Validate(CustomSoapHeader); 
    // then get data from database 
    } 

는 C# 코드는이 웹 서비스를 소비하기 위해 스택 추적에 다음 오류가 표시됩니다.

"{System.Net.WebException : 요청이 빈 응답으로 실패했습니다 .Web.Services.Protocols에서 . SoapHttpClientProtocol.ReadResponse (SoapClientMessage 메시지, WebResponse를 응답 스트림 responseStream, 부울 asyncCall) System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke에서 (문자열 methodName로, 개체 [] 매개 변수) "

두 사이트 모두 윈도우 서버에서 호스팅되는 IIS 7

나는이 오류를 해결하기 위해 지난 2 일부터 인터넷을 검색 한하지만 내 상황에 적용 할 수있는 솔루션을 찾을 수 없습니다와 웹.

어떤 조언/제안을 감상 할 수있다.

답변

0

당신은 바인딩 구성과 같은 HTTPS 엔드 포인트를 통해 통신하도록 클라이언트를 구성해야합니다. 따라서 응용 프로그램 구성에 설정을 입력하고 servicename을 구성하십시오.

<system.serviceModel> 
    <bindings> 
    <basicHttpBinding> 
      <binding name="HttpsBindindConfiguration"> 
      <security mode="Transport" />   
      </binding> 
    </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="https://abc/ListData.asmx" binding="basicHttpBinding" bindingConfiguration="HttpsBindindConfiguration" contract="ListDataClient" name="ListDataClient" /> 
    </client> 
    </system.serviceModel> 
+0

나는 당신의 제안을 시도했으나 이제는 오류가 발생한다. - {System.Net.WebException : HTTP 상태 403 : Forbidden으로 요청이 실패했습니다. 에서 System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse (SoapClientMessage 메시지, WebResponse 응답, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke (String methodName, Object [] parameters) – user1254053

+0

Are 너 프록시 사용? 또한 appconfig 파일을 공유 하시겠습니까? – lucky

+0

모든 설정 파일에 아무 것도 추가하지 않았습니다. – user1254053