2011-06-10 61 views
0

我想從我的asp.net代碼中調用一些用Java編寫的Web服務。我不知道Java。從.Net項目調用Java Web服務 - 處理數組

有幾種方法都有多個屬性。這些方法然後被傳遞給一個控制方法。如何處理數組會發生問題。我似乎無法得到正確的語法。

例如,可以有1到n個位置。每個位置都有多個屬性。 我可以建立一個位置。但是,我如何構建一組位置?我嘗試了幾種方法。這是我得到的最接近的。它符合下面第三行到最後一行的衝突。我刪除了與解釋問題無關的代碼。

錯誤說:對象引用未設置爲對象的實例。

WebReferenceMERegistration.getMERegistration _myMERegistration = 
     new WebReferenceMERegistration.getMERegistration(); 


      WebReferenceMERegistration.Locations _myLocation = 
       new WebReferenceMERegistration.Locations(); 

      WebReferenceMERegistration.Locations[] _myLocations = null; 



      _myLocation.AddressLine1 = txtEmployerAddress1.Text; 
      _myLocation.AddressLine2 = txtEmployerAddress2.Text; 
    // more properties set here 

      _myLocations[0] = _myLocation; 

    _myMERegistration.Locations = _myLocations; 

       _Results = _myRegistrationService.getMERegistration(_myMERegistration); 

回答

0
int length = ...; 
WebReferenceMERegistration.Locations[] _myLocations = 
    new WebReferenceMERegistration.Locations[length]; 
+0

感謝,馬特。你是一個拯救生命的人。 – 2011-06-13 15:43:34