私は2つのasp.net Webサイト(abcとpqrと言う)を持っています。最初のアプリケーション 'abc'にはWebサービスのListData.asmxがあり、2番目のアプリケーションpqrにはそのWebサービスを使用するWebページがあります。 'abc'アプリケーションはhttps上で動作し、 'pqr'はhttp上で動作します。 'ABCサイト' に関するASMXのためのコードは次のとおりです。SOAPエラーまたは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);
は私が
'サービス参照の追加' を介してWebサービスの参照を追加しました:
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#のコードは、このWebサービスを消費するにはスタックトレースは、次のエラーを示します。
"{System.Net.WebException:空の応答で要求が失敗しました。 at System.Web.Services.Protocols。 SoapHttpClientProtocol.ReadResponse(SoapClientMessageメッセージ、にWebResponse応答、ストリームresponseStream、ブールasyncCall)System.Web.Services.Protocols.SoapHttpClientProtocol.Invokeで (文字列methodNameの、オブジェクト[]パラメータ)」
両方のサイトでは、Windows Server上でホストされていますこのエラーを解決するために最後の2日間インターネットを検索していましたが、私の状況で適用できる解決策が見つかりませんでした。
ご意見やご提案がありがとうございます。
私はあなたの提案を試みましたが、今私にエラーが表示されます - {System.Net.WebException:HTTPステータス403:要求が失敗しました。 at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessageメッセージ、WebResponse応答、StreamResponseStream、Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName、Object [] parameters) – user1254053
Areプロキシを使用していますか?また、appconfigファイルを共有しますか? – lucky
私は設定ファイルに何も追加していません。 – user1254053