开发者

Calling a Java Web Service from a .Net Project - Handling arrays

I am trying to call some web services written in Java from my asp.net code. I don't know Java.

There are several methods each with multiple properties. These methods are then passed to one controlling method. The problem occurs with how to handle arrays. I cannot seem to get the syntax quite right.

For example, there can be from 1 to n locations. Each location has multiple properties. I can build one location ok. But how do I build an array of locations? I tried several approaches. Here is the closest I’ve gotten. It complies but crashes on the third to the last line below. I’ve removed the code that is not relevant to explaining the problem.

The error says: Object reference not set to an instance of an object.

开发者_如何转开发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);


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜