简体   繁体   English

从 a.Net 项目调用 Java Web 服务 - 处理 arrays

[英]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.我正在尝试从我的 asp.net 代码中调用一些用 Java 编写的 web 服务。 I don't know Java.我不知道 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.如何处理 arrays 会出现问题。 I cannot seem to get the syntax quite right.我似乎无法完全正确地使用语法。

For example, there can be from 1 to n locations.例如,可以有 1 到 n 个位置。 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.错误提示:Object 引用未设置为 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];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM