2012-04-18 9 views
1

enter image description hereWebServiceの

は、私は、リバースプロキシの背後にあるWebサービスを持っています。現在、WebサービスをテストするWeb参照を追加しようとすると、wsdlファイルをダウンロードできないというメッセージが表示されます。これは、リクエストが送信されたときにhttps://uat.mywebservice.com/Service/Service.asmxですが、リバースプロキシに当たってwsdlとdiscoファイルをダウンロードすると、http://myservice.comp.com/Service/Service.asmx?wsdlにリンクが変更され、myservice.comp.comが正しいリンクではないためです。リバースプロキシ上の名前空間。何が起こっているのは、soapファイルのヘッダーがuat.mywebservice.comという実際のホスト名ではなく、この名前空間に更新されていることです。これは、フィドラーディスコファイルに不正なアドレスがあることがわかりました。私はwsdl.exeツールを使用してプロキシクラスを作成し、正しいホスト名にそのクラスのすべての不正なリンクを更新して解決しました。

リバースプロキシを使用しているときにアドレスが正しいことを確認できる方法はありますか。

誤った:私は同様の問題を解決するためにやった

<?xml version="1.0" encoding="utf-8" ?> 
- <discovery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/disco/"> 
<contractRef ref="http://mvwebservice.comp.com/Service/Service.asmx?wsdl" docRef="http://mvwebservice.comp.com/Service/Service.asmx" xmlns="http://schemas.xmlsoap.org/disco/scl/" /> 
<soap address="http://mywebservice.comp.com/Service/Service.asmx" xmlns:q1="http://tempuri.org/" binding="q1:ServiceSoap" xmlns="http://schemas.xmlsoap.org/disco/soap/" /> 
<soap address="http://mywebservice.comp.com/Service/Service.asmx" xmlns:q2="http://tempuri.org/" binding="q2:ServiceSoap12" xmlns="http://schemas.xmlsoap.org/disco/soap/" /> 
</discovery> 

正しい

<?xml version="1.0" encoding="utf-8" ?> 
- <discovery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/disco/"> 
<contractRef ref="https://uat.mvwebservice.com/Service/Service.asmx?wsdl" docRef="https://uat.mvwebservice.com/Service/Service.asmx" xmlns="http://schemas.xmlsoap.org/disco/scl/" /> 
<soap address="https://uat.mywebservice.com/Service/Service.asmx" xmlns:q1="http://tempuri.org/" binding="q1:ServiceSoap" xmlns="http://schemas.xmlsoap.org/disco/soap/" /> 
<soap address="https://uat.mywebservice.com/Service/Service.asmx" xmlns:q2="http://tempuri.org/" binding="q2:ServiceSoap12" xmlns="http://schemas.xmlsoap.org/disco/soap/" /> 
</discovery> 
+0

をweb.configのためにこれを追加します問題はhttp://blog.graffen.dk/post/Accessing-a-NET-Web-Service-located-behind-a-proxy.aspxです。私は既にここで提案されているソリューションを試しています。 .Net環境でうまく動作します。私は異なるプラットフォーム上のクライアントがどのように動作するのかは分かりません – Pinu

答えて

1

は正しいヘッダを発するようにWebサービスを強制することでした。

App_Codeフォルダーに以下のクラスを作成
  1. :これは、によって行われた

    using System; 
    using System.Web.Services.Description; 
    
    
    namespace Msdn.Web.Services.Samples 
    { 
        /// <summary> 
        /// Summary description for WSDLReflector 
        /// </summary> 
        public class WSDLReflector : SoapExtensionReflector 
        { 
         public override void ReflectMethod() 
         { 
          //no-op 
         } 
    
         public override void ReflectDescription() 
         { 
          ServiceDescription description = ReflectionContext.ServiceDescription; 
          foreach (Service service in description.Services) 
          { 
           foreach (Port port in service.Ports) 
           { 
            foreach (ServiceDescriptionFormatExtension extension in port.Extensions) 
            { 
             SoapAddressBinding binding = extension as SoapAddressBinding; 
             if (null != binding) 
             { 
              binding.Location = binding.Location.Replace("http://mywebservice.comp.com", "https://uat.mywebservice.com"); 
             } 
            } 
           } 
          } 
         } 
        } 
    } 
    
  2. とこれがexcatly何私である

    <webServices> 
        <diagnostics suppressReturningExceptions="true" /> 
        <soapExtensionReflectorTypes> 
         <add type="Msdn.Web.Services.Samples.WSDLReflector,App_Code"/> 
        </soapExtensionReflectorTypes> 
    </webServices>