2012-01-19 19 views
1

我剛剛在Visual Studio中使用服務引用,並試圖使用Java Web服務。我已經使用嚮導添加了服務引用。該向導構建了代理代碼並將端點添加到配置文件。從服務調用引用到Java Web Service什麼也沒有返回

Java端點將自定義類型作爲單個參數。我通過代理對象填充了對象,並將其傳遞給服務。但是當我查看響應對象時,所有的屬性都是空的。沒有錯誤被拋出。請注意,當我使用soapUI時,我可以編輯併發送XML到服務併成功獲得響應。如果發生錯誤,我可以查看在soapUI中發回的XML錯誤消息。

下面是調用代碼:

static void CallJavaEndPoint() 
{ 
    IFX_ProductInqRq inqRQ = new IFX_ProductInqRq(); 
    IFX_ProductInqRqCatSvcRq[] CatSvcRqCollection = new IFX_ProductInqRqCatSvcRq[1]; 
    IFX_ProductInqRqCatSvcRq CatSvcRqItem = new IFX_ProductInqRqCatSvcRq(); 
    IFX_ProductServiceReference.FX_Product_PortTypeClient proxy = new FX_Product_PortTypeClient(); 
    IFX_ProductInqRs response; 

    // Remove other code for setting properties for brevity 
    CatSvcRqItem.RequestID = "123456"; 
    CatSvcRqCollection[0] = CatSvcRqItem; 
    inqRQ.CatSvcRq = CatSvcRqCollection; 

    // reponse just comes back null, no errors 
    response = proxy.IFX_CustomerAccountDetailInquiry(inqRQ); 
} 

從配置文件:

<basicHttpBinding> 
     <binding name="IFX_Product_Binding" closeTimeout="00:01:00" 
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
      maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
      useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
       maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <security mode="Transport"> 
       <transport clientCredentialType="None" proxyCredentialType="None" 
        realm="" /> 
       <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
     </binding> 
     <binding name="IFX_Product_Binding1" closeTimeout="00:01:00" 
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
      maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
      useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
       maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <security mode="None"> 
       <transport clientCredentialType="None" proxyCredentialType="None" 
        realm="" /> 
       <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
     </binding> 
    </basicHttpBinding> 
</bindings> 
<client> 
    <endpoint address="https://example.com/EX_IFXProduct/services/Product_SoapPort_1234" 
     binding="basicHttpBinding" bindingConfiguration="IFX_Product_Binding" 
     contract="IFX_ProductServiceReference.IFX_Product_PortType" 
     name="Product_SoapPort_1234" /> 
</client> 

問題:

  1. 我是否正確調用Java Web服務?
  2. 如何查看返回的XML錯誤?
  3. 我最好使用Web引用或WebRequest/HttpWebRequest連接到此Java Web服務?

回答

1

您可以使用像Fiddler這樣的工具來檢查您從代碼發送的請求/響應,然後將其與通過SoapUI發送的成功請求進行比較。

+0

嘗試Fiddler,它發送請求,但服務不發送迴應。如果我複製顯示在Fiddler中的XML並在soapUI中使用它,它確實會返回一條消息。我想知道是否需要更改配置信息。 – Josh

1

您需要做的是檢查生成的Reference.cs文件。將會有幾個不同的名稱空間屬性。當您使用SoapUI檢查響應時,您會發現正確的名稱空間。將Reference.cs文件中的所有名稱空間引用替換爲您在SoapUI響應中找到的名稱空間。

當您完成替換名稱空間時,您會看到現在序列化的響應很好。

請記住,Reference.cs是生成的文件,並且在更新服務引用時會丟失更改。