问:
This app won't run unless you update Google Play services error
I'm kind of lost right now.
I'm implementing an Android application using Google maps.

In order to make it work I followed some tutorials which were pretty efficient. However I'm stuck with this ":

To fix, this problem I found some tricks here or here which tell that to solve this issue you have to take a special configuration for the emulator, here is mine:

and to install some .apk on the emulator.

And the magic is supposed to be done and the map is supposed to appear which is not my case.

I checked that my extras were well installed:

Here is my AndroidManifest:

```<code><?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="mypack"
          android:versionCode="1"
          android:versionName="1.0">

    <uses-sdk android:minSdkVersion="16"/>

    <permission android:name="mypack.permission.MAPS_RECEIVE"
                android:protectionLevel="signature"/>
    <uses-permission android:name="mypack.permission.MAPS_receive"/>

    <!-- Permission pour utiliser la connexion internet -->
    <uses-permission android:name="android.permission.INTERNET" />
    <!-- Permission permettant de vérifier l'état de la connexion -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- Permission pour stocker des données en cache de la map -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <uses-feature
            android:glEsVersion="0x00020000"
            android:required="true" />

    <application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
        <meta-data
                android:name="com.google.android.maps.v2.API_KEY"
                android:value="MYKEY" />

        <meta-data android:name="com.google.android.gms.version"
                   android:value="@integer/google_play_services_version" />

        <activity android:name="Home"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>

</manifest>
</code>```

Here is my MainActivity

```<code>import android.app.Activity;
import android.os.Bundle;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;

public class Home extends Activity {
    /**
     * Called when the activity is first created.
     */
    private GoogleMap map;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    }
}
</code>```

and the corresponding layout:

```<code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
        >
    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/map"
              android:name="com.google.android.gms.maps.MapFragment"
              android:layout_width="match_parent"
              android:layout_height="match_parent" />
</LinearLayout>
</code>```

Hope to find some fix or what I missed here, thank you in advance.

答:
I had a problem getting this error and hitting the 'Update' button did nothing, it was stuck on a loop, what worked is the following (in Android Studio):

Go to Tools > Android > SDK Manager

Check the 'Show Package Details' option

Under the Android version you want (7.1.1 for me right now), check Google Play Intel x86 Atom System Image

Hit Apply/OK and let the image install

Now go to Tools > Android > AVD Manager

Create Virtual Device

Select one of the devices with a Google Play logo:

Run your app in the new emulator. You can now hit 'Update' when you get the error, update Google Play Services via the Play Store on your device, and test your app in peace.

Body:
I'm kind of lost right now.
I'm implementing an Android application using Google maps.

In order to make it work I followed some tutorials which were pretty efficient. However I'm stuck with this ":

To fix, this problem I found some tricks here or here which tell that to solve this issue you have to take a special configuration for the emulator, here is mine:

and to install some .apk on the emulator.

And the magic is supposed to be done and the map is supposed to appear which is not my case.

I checked that my extras were well installed:

Here is my AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="mypack"
          android:versionCode="1"
          android:versionName="1.0">

    <uses-sdk android:minSdkVersion="16"/>

    <permission android:name="mypack.permission.MAPS_RECEIVE"
                android:protectionLevel="signature"/>
    <uses-permission android:name="mypack.permission.MAPS_receive"/>

    <uses-permission android:name="android.permission.INTERNET" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <uses-feature
            android:glEsVersion="0x00020000"
            android:required="true" />

    <application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
        <meta-data
                android:name="com.google.android.maps.v2.API_KEY"
                android:value="MYKEY" />

        <meta-data android:name="com.google.android.gms.version"
                   android:value="@integer/google_play_services_version" />

        <activity android:name="Home"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>

</manifest>

Here is my MainActivity

import android.app.Activity;
import android.os.Bundle;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;

public class Home extends Activity {
    /**
     * Called when the activity is first created.
     */
    private GoogleMap map;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    }
}

and the corresponding layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
        >
    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/map"
              android:name="com.google.android.gms.maps.MapFragment"
              android:layout_width="match_parent"
              android:layout_height="match_parent" />
</LinearLayout>

Hope to find some fix or what I missed here, thank you in advance.


来源: stackexchange

问:
Call function from current component (router-outlet) when clicking on item menu
I have an app with a menu and a router-outlet where the different components are displayed. All those components have forms with a saveForm function. I would like to know how I can call the saveForm function from the current component when I click an item of the menu. Also how to stop propagation (or prevent default) if the form hasn't been saved.

app.component.html:

```<code>...
<app-navbar></app-navbar>
<router-outlet></router-outlet>
...
</code>```

component1.component.ts:

```<code>...
saveForm() {

}
</code>```

componentN.component.ts:

```<code>...
saveForm() {

}
</code>```

答:
I solved it. I created a shared service:

```<code>@Injectable()
export class MenuFormService {
    private menuFormAnounceClickSubject = new Subject();
    private menuFormConfirmationSavedSubject = new Subject<boolean>();

    menuFormAnounceClick$ = this.menuFormAnounceClickSubject.asObservable();
    menuFormConfirmationSaved$ = this.menuFormConfirmationSavedSubject.asObservable();

    anounceClickMenuForm() {
        this.menuFormAnounceClickSubject.next();
    }

    confirmSaveMenuForm(saved: boolean) {
        this.menuFormConfirmationSavedSubject.next(saved);
    }
}
</code>```

In the menu component:

```<code>export class MenuComponent implements OnInit {
    currentRouteItemMenu: string;

    constructor(
        private menuFormService: MenuFormService,
        private router: Router
    ) {}

    ngOnInit(): void {
        this.menuFormService.menuFormConfirmationSaved$.subscribe(
            saved => {
                if (saved) {
                    this.router.navigate([this.rutaItemActual]);
                }
            });
    }

    onClick(currentRouteItemMenu: string): void {
        this.currentRouteItemMenu = currentRouteItemMenu;
        this.menuFormService.anounceClickMenuForm();
    }
}
</code>```

In every component with forms:

```<code>export class NComponent implements OnInit, OnDestroy {
    subscription: Subscription;

    constructor(
        private menuFormService: MenuFormService
    ) {}

    ngOnInit(): void {
        this.subscription = this.menuFormService.menuFormAnounceClick$.subscribe(
            response => {
                if (this.form.valid) {
                    this.menuFormService.confirmSaveMenuForm(true);
                } else {
                    this.menuFormService.confirmSaveMenuForm(false);
                }
        });

    ngOnDestroy(): void {
        this.subscription.unsubscribe();
    }
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have an app with a menu and a router-outlet where the different components are displayed. All those components have forms with a saveForm function. I would like to know how I can call the saveForm function from the current component when I click an item of the menu. Also how to stop propagation (or prevent default) if the form hasn't been saved.

app.component.html:

...
<app-navbar></app-navbar>
<router-outlet></router-outlet>
...

component1.component.ts:

...
saveForm() {

}

componentN.component.ts:

...
saveForm() {

}

Body:
I solved it. I created a shared service:

@Injectable()
export class MenuFormService {
    private menuFormAnounceClickSubject = new Subject();
    private menuFormConfirmationSavedSubject = new Subject<boolean>();

    menuFormAnounceClick$ = this.menuFormAnounceClickSubject.asObservable();
    menuFormConfirmationSaved$ = this.menuFormConfirmationSavedSubject.asObservable();

    anounceClickMenuForm() {
        this.menuFormAnounceClickSubject.next();
    }

    confirmSaveMenuForm(saved: boolean) {
        this.menuFormConfirmationSavedSubject.next(saved);
    }
}

In the menu component:

export class MenuComponent implements OnInit {
    currentRouteItemMenu: string;

    constructor(
        private menuFormService: MenuFormService,
        private router: Router
    ) {}

    ngOnInit(): void {
        this.menuFormService.menuFormConfirmationSaved$.subscribe(
            saved => {
                if (saved) {
                    this.router.navigate([this.rutaItemActual]);
                }
            });
    }

    onClick(currentRouteItemMenu: string): void {
        this.currentRouteItemMenu = currentRouteItemMenu;
        this.menuFormService.anounceClickMenuForm();
    }
}

In every component with forms:

export class NComponent implements OnInit, OnDestroy {
    subscription: Subscription;

    constructor(
        private menuFormService: MenuFormService
    ) {}

    ngOnInit(): void {
        this.subscription = this.menuFormService.menuFormAnounceClick$.subscribe(
            response => {
                if (this.form.valid) {
                    this.menuFormService.confirmSaveMenuForm(true);
                } else {
                    this.menuFormService.confirmSaveMenuForm(false);
                }
        });

    ngOnDestroy(): void {
        this.subscription.unsubscribe();
    }
}


问:
How can I use API-Gateway as reverse proxy of CloudSearch?
I would like to use API-Gateway to solve two problems for directly accessing CloudSearch

enable CORS (which CloudSearch does not seem to have an out-of-box solution)

open the query only to authenticated users (API-Gateway's authorizer can achieve this)

Here is my question: do I need to use lambda function to invoke the CloudSearch or can I directly set the HTTP integration at API-Gateway?

答: As you can integrate HTTP endpoint from API gateway you can directly call HTTP instead of going through Lambda</p>


问:
Sending shopping cart items to PayPal
I have a database table full of items that were selected to be purchased by a customer, and need to send them to PayPal as an order so they can pay for those items.

My problem is that existing shopping cart solutions require you to either manually enter each existing product into their database online (which is pointless for me, since we have over 1000 products, and over 500 variations of each product), or they require you to have your database table setup a certain way, and I have tried that, with 4carts, including one that I paid a great deal amount of money for, but refuse to offer support for it, and it is abosultely useless.

So, my solution is to roll out my own payment page where i grab the order details (product name, qty, price and freight charges from the database, then send them to PayPal, and from there on, paypal handles the rest.

But I have no idea how I would even begin doing this, and I have studied the PayPal website, and it all seems so confusing and I just don't know where to begin. Are there any working samples floating around that you could please share with me?

I just need to be able to send what's in my database to paypal so the user can pay for those items.

Any help at all is greatly appreciated.

Thank you!

答:
Follow the instructions for  Implementing the Simplest Express Checkout Integration.

It is a little long but it explains exactly what you need to do, and isn't subject to the security hole Robert talks about in his comments.

ContentLicense: CC BY-SA 2.5

Title: Sending shopping cart items to PayPal


问:
How to make 0 in all column in a specific table where value is null using MSSQL
Let the table name is "MyTable"

My current data looks like:

Following, I need after a query on above table:

Actually I need to update all column where value is "NULL", in a single query.

答:
You can use something like this.
It is elegant, but it will update all columns in the table. Huge tables might kill the server

```<code>DECLARE @TableName sysname = 'tablename'
Declare @UptQuery varchar(max)

Select @UptQuery = stuff(T.X.query('name').value('.', 'varchar(max)'), 1, 1, '')
from
(Select ','+name + '=ISNULL('+name+', 0)' name from
    sys.columns where object_id = object_id(@TableName) for xml path(''), type) T(X)

exec ('Update ' + @TableName + ' set ' + @UptQuery)
</code>```

Old answer
It will go through all columns for a table and update everything with 0 if it is null. It is a lot of updates, and I think it is still better to design the table correctly from the start.

```<code>DECLARE @TableName sysname = 'tablename'
Declare @ColName sysname

Select name into #temp from sys.columns where object_id = object_id(@TableName)
while(0 < (Select count(1) from  #temp))
BEGIN
  SET ROWCOUNT 1
  Select @ColName = name from #temp
  SET ROWCOUNT 0
  exec('Update ' + @TableName + ' set ' + @ColName + ' = ISNULL('+@ColName+', 0) where ' + @ColName + ' is null')
  delete #temp where name = @ColName
END
</code>```

Body:
You can use something like this.
It is elegant, but it will update all columns in the table. Huge tables might kill the server

DECLARE @TableName sysname = 'tablename'
Declare @UptQuery varchar(max)

Select @UptQuery = stuff(T.X.query('name').value('.', 'varchar(max)'), 1, 1, '')
from
(Select ','+name + '=ISNULL('+name+', 0)' name from
    sys.columns where object_id = object_id(@TableName) for xml path(''), type) T(X)

exec ('Update ' + @TableName + ' set ' + @UptQuery)

Old answer
It will go through all columns for a table and update everything with 0 if it is null. It is a lot of updates, and I think it is still better to design the table correctly from the start.

DECLARE @TableName sysname = 'tablename'
Declare @ColName sysname

Select name into #temp from sys.columns where object_id = object_id(@TableName)
while(0 < (Select count(1) from  #temp))
BEGIN
  SET ROWCOUNT 1
  Select @ColName = name from #temp
  SET ROWCOUNT 0
  exec('Update ' + @TableName + ' set ' + @ColName + ' = ISNULL('+@ColName+', 0) where ' + @ColName + ' is null')
  delete #temp where name = @ColName
END


问:
How to align text vertically in panel using bootstrap 3
I have an image and a description of a panel panel-default. The image is pulled to the left and the description is on the right side.

The image has the img-responsive class so when I resize the window it fits the panel body.

The question is how can I achieve the same effect with the description. I would like to align it vertically to the panel and when I resize the window it should also fit the panel body.

What I have tried so far:

.container {
  padding-top: 30px;
}

p {
  font-size: 2vw;
}

.panel {
  border-radius: 0;
}

.panel-body {
  padding: 0;
}

.panel-description {
  margin-top 12px;
  padding-left: 3px;
}

.vertical-center {
  display: flex;
  align-items: center;
}

.no-padding {
  padding: 0;
}

.no-padding-right {
  padding-right: 0;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
  <div class="row">
    <div class="col-sm-4 col-lg-4">
      <div class="panel panel-default">
        <div class="panel-body">
          Basic panel example
        </div>
      </div>
    </div>
    <div class="col-sm-4 col-lg-4">
      <div class="panel panel-default">
        <div class="panel-body">
          <div class="row">
            <div class="col-sm-4 col-md-4 no-padding-right">
              <div class="panel-image">
                <img src="http://via.placeholder.com/150x150" class="img-responsive" alt="img">
              </div>
            </div>
            <div class="col-sm-8 col-md-8 no-padding">
              <div class="panel-description vertical-center">
                <p>Name<br>Surname</p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="col-sm-4 col-lg-4">
      <div class="panel panel-default">
        <div class="panel-body">
          Basic panel example
        </div>
      </div>
    </div>
  </div>
</div></code>```

I added

```<code>.vertical-center {
   display: flex;
   align-items: center;
}
</code>```

to the .panel-description but it's not working.

What is the best solution for this problem?

https://jsfiddle.net/DTcHh/39282/

答:
I made little change in your code and its working well now. Here is the updated code for your reference

.container {
  padding-top: 30px;
}

p {
  font-size: 2vw;
}

.panel {
  border-radius: 0;
}

.panel-body {
  padding: 0;
}

.panel-description {
  margin-top 12px;
  padding-left: 3px;
}

.no-padding-right {
  padding-right: 0;
}

.main-class {
  display: flex;
  width: 100%;
  flex-wrap: wrap;
  align-items: center;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="container">
  <div class="row">
    <div class="col-sm-4 col-lg-4">
      <div class="panel panel-default">
        <div class="panel-body">
          Basic panel example
        </div>
      </div>
    </div>
    <div class="col-sm-4 col-lg-4">
      <div class="panel panel-default">
        <div class="panel-body">
          <div class="row">
            <div class="main-class">
                <div class="col-sm-4 col-md-4 no-padding-right">
                  <div class="panel-image">
                    <img src="http://via.placeholder.com/150x150" class="img-responsive" alt="img">
                  </div>
                </div>
                <div class="col-sm-8 col-md-8 no-padding">
                  <div class="panel-description vertical-center">
                    <p>Name<br>Surname</p>
                  </div>
                </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="col-sm-4 col-lg-4">
      <div class="panel panel-default">
        <div class="panel-body">
          Basic panel example
        </div>
      </div>
    </div>
  </div>
</div></code>```

Body:
I have an image and a description of a panel panel-default. The image is pulled to the left and the description is on the right side.

The image has the img-responsive class so when I resize the window it fits the panel body.

The question is how can I achieve the same effect with the description. I would like to align it vertically to the panel and when I resize the window it should also fit the panel body.

What I have tried so far:

.container {
  padding-top: 30px;
}

p {
  font-size: 2vw;
}

.panel {
  border-radius: 0;
}

.panel-body {
  padding: 0;
}

.panel-description {
  margin-top 12px;
  padding-left: 3px;
}

.vertical-center {
  display: flex;
  align-items: center;
}

.no-padding {
  padding: 0;
}

.no-padding-right {
  padding-right: 0;
}

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

          Basic panel example

Name
Surname

          Basic panel example

I added

.vertical-center {
   display: flex;
   align-items: center;
}

to the .panel-description but it's not working.

What is the best solution for this problem?

https://jsfiddle.net/DTcHh/39282/

Body:
I made little change in your code and its working well now. Here is the updated code for your reference

.container {
  padding-top: 30px;
}

p {
  font-size: 2vw;
}

.panel {
  border-radius: 0;
}

.panel-body {
  padding: 0;
}

.panel-description {
  margin-top 12px;
  padding-left: 3px;
}

.no-padding-right {
  padding-right: 0;
}

.main-class {
  display: flex;
  width: 100%;
  flex-wrap: wrap;
  align-items: center;
}

<div class="container">
  <div class="row">
    <div class="col-sm-4 col-lg-4">
      <div class="panel panel-default">
        <div class="panel-body">
          Basic panel example
        </div>
      </div>
    </div>
    <div class="col-sm-4 col-lg-4">
      <div class="panel panel-default">
        <div class="panel-body">
          <div class="row">
            <div class="main-class">
                <div class="col-sm-4 col-md-4 no-padding-right">
                  <div class="panel-image">
                    <img src="http://via.placeholder.com/150x150" class="img-responsive" alt="img">
                  </div>
                </div>
                <div class="col-sm-8 col-md-8 no-padding">
                  <div class="panel-description vertical-center">
                    <p>Name<br>Surname</p>
                  </div>
                </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="col-sm-4 col-lg-4">
      <div class="panel panel-default">
        <div class="panel-body">
          Basic panel example
        </div>
      </div>
    </div>
  </div>
</div>


问:
Safe handling of userspace pointers in a driver?
I'm writing an ioctl driver that needs to read and write data to userspace. For visualization, here's a typical argument that goes in a driver call:

```<code>typedef struct {
unsigned int* src;
unsigned int* dst;
unsigned int buffer_size;
unsigned int key[8];
} aes_data
</code>```

I'm not very well-versed in how virtual memory works, but I think there's a risk here. The userspace process could have provided a pointer to memory it does not own. The provided buffer size could cause an overflow into the memory of some other process as well. How do I handle these userspace pointers responsibly in my driver?

答:
How do I handle these userspace pointers responsibly in my driver?

You don't, simply because there are no ways to check if the pointers points to anything valid. It is up to the user of the ioctl() to provide proper parameters. If they fail to do that, then tough luck for them.

Body:
I'm writing an ioctl driver that needs to read and write data to userspace. For visualization, here's a typical argument that goes in a driver call:

typedef struct {
unsigned int* src;
unsigned int* dst;
unsigned int buffer_size;
unsigned int key[8];
} aes_data

I'm not very well-versed in how virtual memory works, but I think there's a risk here. The userspace process could have provided a pointer to memory it does not own. The provided buffer size could cause an overflow into the memory of some other process as well. How do I handle these userspace pointers responsibly in my driver?


问:
Why overloaded methods defined in OOPS?
Interviewer had asked me what is method overloading and I had given answer saying, method overloading is within same class where two or more methods have same name but different signature, with following example -

```<code>//method with two parameters
public int add(int a, int b){
  return a + b;
}

//method with three parameters
public int add(int a, int b, int c){
  return a + b + c;
}
</code>```

To this example, he said why do we need two methods with same name i.e. add. Instead we can have two methods with different names i.e. addTwoNumbers and addThreeNumbers which indicates, method names are more verbose and if we follow this approach, we don't need method overloading. (And same is true for other Java apis where method overloading is used.)

Considering his above thought, he asked why OOPS principle still have method overloading and why is being used so intensively? What is intention of inventors to introduce concept of method overloading?

答:
Why function overloading at all? When action is almost same, just the set of inputs are different.

In Java, using function overloading, we can support the concept of optional parameter (as there is no direct support for it in Java)

```<code>String formatStr(String str){   //if you don't care about having a different choice than default
   String defaultPrefix = "__";
   return formatStr(str, defaultPrefix);
}

String formatStr(String str, String prefix){  //You are free to choose whatever prefix you want.
    return prefix + str;
}
</code>```

Title: Why overloaded methods defined in OOPS?

Body:
Interviewer had asked me what is method overloading and I had given answer saying, method overloading is within same class where two or more methods have same name but different signature, with following example -

//method with two parameters
public int add(int a, int b){
  return a + b;
}

//method with three parameters
public int add(int a, int b, int c){
  return a + b + c;
}

To this example, he said why do we need two methods with same name i.e. add. Instead we can have two methods with different names i.e. addTwoNumbers and addThreeNumbers which indicates, method names are more verbose and if we follow this approach, we don't need method overloading. (And same is true for other Java apis where method overloading is used.)

Considering his above thought, he asked why OOPS principle still have method overloading and why is being used so intensively? What is intention of inventors to introduce concept of method overloading?

Body:
Why function overloading at all? When action is almost same, just the set of inputs are different.

In Java, using function overloading, we can support the concept of optional parameter (as there is no direct support for it in Java)

String formatStr(String str){   //if you don't care about having a different choice than default
   String defaultPrefix = "__";
   return formatStr(str, defaultPrefix);
}

String formatStr(String str, String prefix){  //You are free to choose whatever prefix you want.
    return prefix + str;
}


问:
Delphi 2010 or c# - webservice
I am trying use webserivce with Delphi 2010 but i cant get the gettransaction to work right. How do i use delphi to get the reponse from this function? I can insert the parameter to call it but not get the response.

How can i use the Delphi or c# to read the repsonse?

This is the XML:

```<code><?xml version="1.0" encoding="UTF-8"?>
</code>```

```<code>      <xsd:complexType name="getTransactions">
        <xsd:sequence>
          <xsd:element name="date_from" nillable="true" type="xsd:string"/>
          <xsd:element name="date_to" nillable="true" type="xsd:string"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="getTransactionsResponse">
        <xsd:sequence>
          <xsd:element name="voucherTransactions" nillable="true" type="tns:ArrayOfVoucherTransaction"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="VoucherTransaction">
        <xsd:sequence>
          <xsd:element name="GLOBAL_SERIAL_NUMBER" nillable="true" type="xsd:string"/>
          <xsd:element name="DATE_CREATED" nillable="true" type="xsd:string"/>
          <xsd:element name="AMOUNT" nillable="true" type="xsd:string"/>
          <xsd:element name="STATUS" nillable="true" type="xsd:string"/>
          <xsd:element name="PIN_CODE" nillable="true" type="xsd:string"/>
          <xsd:element name="EXT_REF" nillable="true" type="xsd:string"/>
          <xsd:element name="STORE_ID" nillable="true" type="xsd:string"/>
          <xsd:element name="TERMINAL_ID" nillable="true" type="xsd:string"/>
          <xsd:element name="EMP_ID" nillable="true" type="xsd:string"/>
          <xsd:element name="DATE_INVALIDATED" nillable="true" type="xsd:string"/>
          <xsd:element name="EXPIRY_DATE" nillable="true" type="xsd:string"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="ArrayOfVoucherTransaction"><xsd:sequence>
</code>```

```<code>      </xsd:complexType>
             <xsd:element name="getTransactions" type="tns:getTransactions"/>
</code>```

I call the webserive with gettransaction with parameter From 01.01.2011 and To 17.01.2011

This is the function look like in delphi 2010

```<code>procedure TForm2.Button2Click(Sender: TObject);
var
  rr     : voucher17.getTransactions2;
  getrr    : voucher17.getTransactionsResponse2;
  aa2    : voucher17.ArrayOfVoucherTransaction;
  iinn   : integer;
  test3  : voucher17.VoucherTransaction;
  test4  : voucher17.ArrayOfVoucherTransaction;
begin

rr := getTransactions2.Create;
rr.date_from := '09.01.2011';
rr.date_to   := '10.01.2011';

getrr := GetVoucher_PortType.getTransactions(rr);

// here is the problem but i dont know how to read from the array
 i have try to assign getrr to test3, test4, aa2 but still cant figure out what to do to get the data.

end;
</code>```

This is the return from soapui so this is working but how can use delphi to read from this?

```<code><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

   <SOAP-ENV:Header xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"/>

   <SOAP-ENV:Body>

      <ser-root:getTransactionsResponse xmlns:ser-root="https://webmethods.someurl.com/TopUpServices/webServices/Voucher">

         <voucherTransactions>

            <ArrayOfVoucherTransactionItem>

               <GLOBAL_SERIAL_NUMBER>3132765</GLOBAL_SERIAL_NUMBER>

               <DATE_CREATED>2011-01-17 20:34:49.0</DATE_CREATED>

               <AMOUNT>500</AMOUNT>

               <STATUS>1</STATUS>

               <PIN_CODE>123</PIN_CODE>

               <EXT_REF>772</EXT_REF>

               <STORE_ID>772</STORE_ID>

               <TERMINAL_ID>772</TERMINAL_ID>

               <EMP_ID>772</EMP_ID>

               <DATE_INVALIDATED>2011-01-17 20:34:49.0</DATE_INVALIDATED>

               <EXPIRY_DATE>2011-01-17 20:34:49.0</EXPIRY_DATE>

            </ArrayOfVoucherTransactionItem>

            <ArrayOfVoucherTransactionItem>

               <GLOBAL_SERIAL_NUMBER>3133023</GLOBAL_SERIAL_NUMBER>

               <DATE_CREATED>2011-01-17 20:34:49.0</DATE_CREATED>

               <AMOUNT>500</AMOUNT>

               <STATUS>1</STATUS>

               <PIN_CODE>123</PIN_CODE>

               <EXT_REF>772</EXT_REF>

               <STORE_ID>772</STORE_ID>

               <TERMINAL_ID>772</TERMINAL_ID>

               <EMP_ID>772</EMP_ID>

               <DATE_INVALIDATED>2011-01-17 20:34:49.0</DATE_INVALIDATED>

               <EXPIRY_DATE>2011-01-17 20:34:49.0</EXPIRY_DATE>

            </ArrayOfVoucherTransactionItem>

         </voucherTransactions>

      </ser-root:getTransactionsResponse>

   </SOAP-ENV:Body>

</SOAP-ENV:Envelope>
</code>```

Here is the proxy

```<code>// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described beloow:
// WSDL     : https://webmethods.someurl.com/ws/TopUpServices.webServices:Voucher?WSDL
//  >Import : https://webmethods.someurl.com/ws/TopUpServices.webServices:Voucher?WSDL>0
// Encoding : UTF-8
// Codegen  : [wfAutoDestroyMembers-, wfMapArraysToClasses+, wfProcessHeaders-, wfUseSettersAndGetters+, wfForceSOAP11+, wfForceSOAP12+]
// Version  : 1.0
// (10.1.2011 15:31:05 - - $Rev: 25127 $)
// ************************************************************************ //

unit Voucher17;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns, Dialogs;

const
  IS_OPTN = $0001;
  IS_UNBD = $0002;
  IS_NLBL = $0004;
  IS_UNQL = $0008;

type

  // ************************************************************************ //
  // The following types, referred to in the WSDL document are not being represented
  // in this file. They are either aliases[@] of other types represented or were referred
  // to but never[!] declared in the document. The types from the latter category
  // typically map to predefined/known XML or Embarcadero types; however, they could also
  // indicate incorrect WSDL documents that failed to declare or import a schema type.
  // ************************************************************************ //
  // !:string          - "http://www.w3.org/2001/XMLSchema"[Gbl]

  getTransactions      = class;                 { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[Lit][GblCplx] }
  getTransactionsResponse = class;              { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[Lit][GblCplx] }
  VoucherTransaction   = class;                 { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[GblCplx] }
  getTransactions2     = class;                 { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[Lit][GblElm] }
  getTransactionsResponse2 = class;             { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[Lit][GblElm] }
  ArrayOfVoucherTransaction = class;            { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[GblCplx] }

  // ************************************************************************ //
  // XML       : getTransactions, global, <complexType>
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  getTransactions = class(TRemotable)
  private
    Fdate_from: string;
    Fdate_to: string;
    function  Getdate_from(Index: Integer): string;
    procedure Setdate_from(Index: Integer; const Astring: string);
    function  Getdate_to(Index: Integer): string;
    procedure Setdate_to(Index: Integer; const Astring: string);
  public
    constructor Create; override;
  published
    property date_from: string  Index (IS_NLBL or IS_UNQL) read Getdate_from write Setdate_from;
    property date_to:   string  Index (IS_NLBL or IS_UNQL) read Getdate_to write Setdate_to;
  end;

  // ************************************************************************ //
  // XML       : getTransactionsResponse, global, <complexType>
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  getTransactionsResponse = class(TRemotable)
  private
    FvoucherTransactions: ArrayOfVoucherTransaction;
    function  GetvoucherTransactions(Index: Integer): ArrayOfVoucherTransaction;
    procedure SetvoucherTransactions(Index: Integer; const AArrayOfVoucherTransaction: ArrayOfVoucherTransaction);
  public
    constructor Create; override;
  published
    property voucherTransactions: ArrayOfVoucherTransaction  Index (IS_NLBL or IS_UNQL) read GetvoucherTransactions write SetvoucherTransactions;
  end;

  // ************************************************************************ //
  // XML       : VoucherTransaction, global, <complexType>
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // ************************************************************************ //
  VoucherTransaction = class(TRemotable)
  private
    FGLOBAL_SERIAL_NUMBER: string;
    FDATE_CREATED: string;
    FAMOUNT: string;
    FSTATUS: string;
    FPIN_CODE: string;
    FEXT_REF: string;
    FSTORE_ID: string;
    FTERMINAL_ID: string;
    FEMP_ID: string;
    FDATE_INVALIDATED: string;
    FEXPIRY_DATE: string;
    function  GetGLOBAL_SERIAL_NUMBER(Index: Integer): string;
    procedure SetGLOBAL_SERIAL_NUMBER(Index: Integer; const Astring: string);
    function  GetDATE_CREATED(Index: Integer): string;
    procedure SetDATE_CREATED(Index: Integer; const Astring: string);
    function  GetAMOUNT(Index: Integer): string;
    procedure SetAMOUNT(Index: Integer; const Astring: string);
    function  GetSTATUS(Index: Integer): string;
    procedure SetSTATUS(Index: Integer; const Astring: string);
    function  GetPIN_CODE(Index: Integer): string;
    procedure SetPIN_CODE(Index: Integer; const Astring: string);
    function  GetEXT_REF(Index: Integer): string;
    procedure SetEXT_REF(Index: Integer; const Astring: string);
    function  GetSTORE_ID(Index: Integer): string;
    procedure SetSTORE_ID(Index: Integer; const Astring: string);
    function  GetTERMINAL_ID(Index: Integer): string;
    procedure SetTERMINAL_ID(Index: Integer; const Astring: string);
    function  GetEMP_ID(Index: Integer): string;
    procedure SetEMP_ID(Index: Integer; const Astring: string);
    function  GetDATE_INVALIDATED(Index: Integer): string;
    procedure SetDATE_INVALIDATED(Index: Integer; const Astring: string);
    function  GetEXPIRY_DATE(Index: Integer): string;
    procedure SetEXPIRY_DATE(Index: Integer; const Astring: string);
  published
    property GLOBAL_SERIAL_NUMBER: string  Index (IS_NLBL or IS_UNQL) read GetGLOBAL_SERIAL_NUMBER write SetGLOBAL_SERIAL_NUMBER;
    property DATE_CREATED:         string  Index (IS_NLBL or IS_UNQL) read GetDATE_CREATED write SetDATE_CREATED;
    property AMOUNT:               string  Index (IS_NLBL or IS_UNQL) read GetAMOUNT write SetAMOUNT;
    property STATUS:               string  Index (IS_NLBL or IS_UNQL) read GetSTATUS write SetSTATUS;
    property PIN_CODE:             string  Index (IS_NLBL or IS_UNQL) read GetPIN_CODE write SetPIN_CODE;
    property EXT_REF:              string  Index (IS_NLBL or IS_UNQL) read GetEXT_REF write SetEXT_REF;
    property STORE_ID:             string  Index (IS_NLBL or IS_UNQL) read GetSTORE_ID write SetSTORE_ID;
    property TERMINAL_ID:          string  Index (IS_NLBL or IS_UNQL) read GetTERMINAL_ID write SetTERMINAL_ID;
    property EMP_ID:               string  Index (IS_NLBL or IS_UNQL) read GetEMP_ID write SetEMP_ID;
    property DATE_INVALIDATED:     string  Index (IS_NLBL or IS_UNQL) read GetDATE_INVALIDATED write SetDATE_INVALIDATED;
    property EXPIRY_DATE:          string  Index (IS_NLBL or IS_UNQL) read GetEXPIRY_DATE write SetEXPIRY_DATE;
  end;

  // ************************************************************************ //
  // XML       : getTransactions, global, <element>
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // Info      : Wrapper
  // ************************************************************************ //
  getTransactions2 = class(getTransactions)
  private
  published
  end;

  // ************************************************************************ //
  // XML       : getTransactionsResponse, global, <element>
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // Info      : Wrapper
  // ************************************************************************ //
  getTransactionsResponse2 = class(getTransactionsResponse)
  private
  published
  end;

  Array_Of_VoucherTransaction = array of VoucherTransaction;   { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[GblUbnd] }

  // ************************************************************************ //
  // XML       : ArrayOfVoucherTransaction, global, <complexType>
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // ************************************************************************ //
  ArrayOfVoucherTransaction = class(TRemotable)
  private
    FArrayOfVoucherTransactionItem: Array_Of_VoucherTransaction;
    function  GetArrayOfVoucherTransactionItem(Index: Integer): Array_Of_VoucherTransaction;
    procedure SetArrayOfVoucherTransactionItem(Index: Integer; const AArray_Of_VoucherTransaction: Array_Of_VoucherTransaction);
  public
    function   GetVoucherTransactionArray(Index: Integer): VoucherTransaction;
    procedure  SetVoucherTransactionArray(Index: Integer; const Item: VoucherTransaction);
    function   GetVoucherTransactionArrayLength: Integer;
    procedure  SetVoucherTransactionArrayLength(Len: Integer);

    property   VoucherTransactionArray[Index: Integer]: VoucherTransaction read GetVoucherTransactionArray write SetVoucherTransactionArray; default;
    property   Len: Integer read GetVoucherTransactionArrayLength write SetVoucherTransactionArrayLength;
  published
    property ArrayOfVoucherTransactionItem: Array_Of_VoucherTransaction  Index (IS_UNBD or IS_UNQL) read GetArrayOfVoucherTransactionItem write SetArrayOfVoucherTransactionItem;
  end;

  // ************************************************************************ //
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // soapAction: TopUpServices_webServices_Voucher_Binder_%operationName%
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : document
  // binding   : TopUpServices_webServices_Voucher_Binder
  // service   : Voucher
  // port      : TopUpServices_webServices_Voucher_Port
  // URL       : https://webmethods.someurl.com:443/ws/TopUpServices.webServices:Voucher
  // ************************************************************************ //
  Voucher_PortType = interface(IInvokable)
  ['{DCE754E5-4B05-3C9B-8078-D4C2BB3F12B4}']

    // Cannot unwrap:
    //     - Input element wrapper name does not match operation's name
    //     - More than one strictly out element was found
     function  getTransactions(const parameters: getTransactions2): getTransactionsResponse2; stdcall;

   end;

function GetVoucher_PortType(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): Voucher_PortType;

implementation
  uses SysUtils;

function GetVoucher_PortType(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): Voucher_PortType;
const
  defWSDL = 'https://webmethods.someurl.com/ws/TopUpServices.webServices:Voucher?WSDL';
  defURL  = 'https://webmethods.someurl.com:443/ws/TopUpServices.webServices:Voucher';
  defSvc  = 'Voucher';
  defPrt  = 'TopUpServices_webServices_Voucher_Port';
var
  RIO: THTTPRIO;
begin
  Result := nil;
  if (Addr = '') then
  begin
    if UseWSDL then
      Addr := defWSDL
    else
      Addr := defURL;
  end;
  if HTTPRIO = nil then
    RIO := THTTPRIO.Create(nil)
  else
    RIO := HTTPRIO;
  try
    Result := (RIO as Voucher_PortType);
    if UseWSDL then
    begin
      RIO.WSDLLocation := Addr;
      RIO.Service := defSvc;
      RIO.Port := defPrt;
    end else
      RIO.URL := Addr;
  finally
    if (Result = nil) and (HTTPRIO = nil) then
      RIO.Free;
  end;
end;

constructor getTransactions.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

function getTransactions.Getdate_from(Index: Integer): string;
begin
  Result := Fdate_from;
end;

procedure getTransactions.Setdate_from(Index: Integer; const Astring: string);
begin
  Fdate_from := Astring;
end;

function getTransactions.Getdate_to(Index: Integer): string;
begin
  Result := Fdate_to;
end;

procedure getTransactions.Setdate_to(Index: Integer; const Astring: string);
begin
  Fdate_to := Astring;
end;

constructor getTransactionsResponse.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

function getTransactionsResponse.GetvoucherTransactions(Index: Integer): ArrayOfVoucherTransaction;
begin
  Result := FvoucherTransactions;
end;

procedure getTransactionsResponse.SetvoucherTransactions(Index: Integer; const AArrayOfVoucherTransaction: ArrayOfVoucherTransaction);
begin
  FvoucherTransactions := AArrayOfVoucherTransaction;
end;

function VoucherTransaction.GetGLOBAL_SERIAL_NUMBER(Index: Integer): string;
begin
  Result := FGLOBAL_SERIAL_NUMBER;
end;

procedure VoucherTransaction.SetGLOBAL_SERIAL_NUMBER(Index: Integer; const Astring: string);
begin
  FGLOBAL_SERIAL_NUMBER := Astring;
end;

function VoucherTransaction.GetDATE_CREATED(Index: Integer): string;
begin
  Result := FDATE_CREATED;
end;

procedure VoucherTransaction.SetDATE_CREATED(Index: Integer; const Astring: string);
begin
  FDATE_CREATED := Astring;
end;

function VoucherTransaction.GetAMOUNT(Index: Integer): string;
begin
  Result := FAMOUNT;
end;

procedure VoucherTransaction.SetAMOUNT(Index: Integer; const Astring: string);
begin
  FAMOUNT := Astring;
end;

function VoucherTransaction.GetSTATUS(Index: Integer): string;
begin
  Result := FSTATUS;
end;

procedure VoucherTransaction.SetSTATUS(Index: Integer; const Astring: string);
begin
  FSTATUS := Astring;
end;

function VoucherTransaction.GetPIN_CODE(Index: Integer): string;
begin
  Result := FPIN_CODE;
end;

procedure VoucherTransaction.SetPIN_CODE(Index: Integer; const Astring: string);
begin
  FPIN_CODE := Astring;
end;

function VoucherTransaction.GetEXT_REF(Index: Integer): string;
begin
  Result := FEXT_REF;
end;

procedure VoucherTransaction.SetEXT_REF(Index: Integer; const Astring: string);
begin
  FEXT_REF := Astring;
end;

function VoucherTransaction.GetSTORE_ID(Index: Integer): string;
begin
  Result := FSTORE_ID;
end;

procedure VoucherTransaction.SetSTORE_ID(Index: Integer; const Astring: string);
begin
  FSTORE_ID := Astring;
end;

function VoucherTransaction.GetTERMINAL_ID(Index: Integer): string;
begin
  Result := FTERMINAL_ID;
end;

procedure VoucherTransaction.SetTERMINAL_ID(Index: Integer; const Astring: string);
begin
  FTERMINAL_ID := Astring;
end;

function VoucherTransaction.GetEMP_ID(Index: Integer): string;
begin
  Result := FEMP_ID;
end;

procedure VoucherTransaction.SetEMP_ID(Index: Integer; const Astring: string);
begin
  FEMP_ID := Astring;
end;

function VoucherTransaction.GetDATE_INVALIDATED(Index: Integer): string;
begin
  Result := FDATE_INVALIDATED;
end;

procedure VoucherTransaction.SetDATE_INVALIDATED(Index: Integer; const Astring: string);
begin
  FDATE_INVALIDATED := Astring;
end;

function VoucherTransaction.GetEXPIRY_DATE(Index: Integer): string;
begin
  Result := FEXPIRY_DATE;
end;

procedure VoucherTransaction.SetEXPIRY_DATE(Index: Integer; const Astring: string);
begin
  FEXPIRY_DATE := Astring;
end;

function ArrayOfVoucherTransaction.GetVoucherTransactionArray(Index: Integer): VoucherTransaction;
begin
  Result := FArrayOfVoucherTransactionItem[Index];
end;

procedure ArrayOfVoucherTransaction.SetVoucherTransactionArray(Index: Integer; const Item: VoucherTransaction);
begin
   FArrayOfVoucherTransactionItem[Index] := Item;
end;

function ArrayOfVoucherTransaction.GetVoucherTransactionArrayLength: Integer;
begin
  if Assigned(FArrayOfVoucherTransactionItem) then
    Result := System.Length(FArrayOfVoucherTransactionItem)
  else
    Result := 0;
end;

procedure ArrayOfVoucherTransaction.SetVoucherTransactionArrayLength(Len: Integer);
begin
  System.SetLength(FArrayOfVoucherTransactionItem, Len);
end;

function ArrayOfVoucherTransaction.GetArrayOfVoucherTransactionItem(Index: Integer): Array_Of_VoucherTransaction;
begin
  Result := FArrayOfVoucherTransactionItem;
end;

procedure ArrayOfVoucherTransaction.SetArrayOfVoucherTransactionItem(Index: Integer; const AArray_Of_VoucherTransaction: Array_Of_VoucherTransaction);
begin
  FArrayOfVoucherTransactionItem := AArray_Of_VoucherTransaction;
end;

initialization
  InvRegistry.RegisterInterface(TypeInfo(Voucher_PortType), 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'UTF-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(Voucher_PortType), 'TopUpServices_webServices_Voucher_Binder_%operationName%');
  InvRegistry.RegisterInvokeOptions(TypeInfo(Voucher_PortType), ioDocument);
  InvRegistry.RegisterInvokeOptions(TypeInfo(Voucher_PortType), ioLiteral);
  InvRegistry.RegisterInvokeOptions(TypeInfo(Voucher_PortType), ioSOAP12);
  InvRegistry.RegisterExternalParamName(TypeInfo(Voucher_PortType), 'invalidateVoucher', 'parameters1', 'parameters');
  InvRegistry.RegisterExternalParamName(TypeInfo(Voucher_PortType), 'getTransactions', 'parameters1', 'parameters');
  InvRegistry.RegisterExternalParamName(TypeInfo(Voucher_PortType), 'createVoucher', 'parameters1', 'parameters');
  RemClassRegistry.RegisterXSClass(getTransactions, 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'getTransactions');
  RemClassRegistry.RegisterSerializeOptions(getTransactions, [xoLiteralParam]);
  RemClassRegistry.RegisterXSClass(getTransactionsResponse, 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'getTransactionsResponse');
  RemClassRegistry.RegisterSerializeOptions(getTransactionsResponse, [xoLiteralParam]);
  RemClassRegistry.RegisterXSClass(VoucherTransaction, 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'VoucherTransaction');
  RemClassRegistry.RegisterXSClass(getTransactions2, 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'getTransactions2', 'getTransactions');
  RemClassRegistry.RegisterXSClass(getTransactionsResponse2, 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'getTransactionsResponse2', 'getTransactionsResponse');
  RemClassRegistry.RegisterXSInfo(TypeInfo(Array_Of_VoucherTransaction), 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'Array_Of_VoucherTransaction');
  RemClassRegistry.RegisterXSClass(ArrayOfVoucherTransaction, 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'ArrayOfVoucherTransaction');

end.
</code>```

答:
Although I don't particular like the MapArraysToClasses option enabled, the following illustrates how to access the data sent back by the service with the proxy you've generated:

```<code>procedure TForm33.Button1Click(Sender: TObject);
var
  rr     : voucher17.getTransactions2;
  getrr    : voucher17.getTransactionsResponse2;
  I: Integer;
begin
  rr := getTransactions2.Create;
  try
    rr.date_from := '09.01.2011';
    rr.date_to   := '10.01.2011';

    getrr := GetVoucher_PortType.getTransactions(rr);
    try
      if Assigned(getrr.voucherTransactions) then
      begin
        for I := 0 to getrr.voucherTransactions.Len-1 do
        begin
          ShowMessage(Format('%s, %s, %s', [
              getrr.voucherTransactions[I].GLOBAL_SERIAL_NUMBER,
              getrr.voucherTransactions[I].DATE_CREATED,
              getrr.voucherTransactions[I].AMOUNT]));
        end;
      end;
    finally
      getrr.Free;
    end;
  finally
    rr.Free;
  end;
end;
</code>```

I'm opting to display the values of three of the fields. You'll probably want to read the other fields as well.

I don't like the fact that AutoDestroyMembers was disabled because even though the code above cleans up the request and response objects, the array of objects contained in the response will not be cleaned up properly:(.

Cheers,

Bruneau

Title: Delphi 2010 or c# - webservice

Body:
I am trying use webserivce with Delphi 2010 but i cant get the gettransaction to work right. How do i use delphi to get the reponse from this function? I can insert the parameter to call it but not get the response.

How can i use the Delphi or c# to read the repsonse?

This is the XML:

<?xml version="1.0" encoding="UTF-8"?>

      <xsd:complexType name="getTransactions">
        <xsd:sequence>
          <xsd:element name="date_from" nillable="true" type="xsd:string"/>
          <xsd:element name="date_to" nillable="true" type="xsd:string"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="getTransactionsResponse">
        <xsd:sequence>
          <xsd:element name="voucherTransactions" nillable="true" type="tns:ArrayOfVoucherTransaction"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="VoucherTransaction">
        <xsd:sequence>
          <xsd:element name="GLOBAL_SERIAL_NUMBER" nillable="true" type="xsd:string"/>
          <xsd:element name="DATE_CREATED" nillable="true" type="xsd:string"/>
          <xsd:element name="AMOUNT" nillable="true" type="xsd:string"/>
          <xsd:element name="STATUS" nillable="true" type="xsd:string"/>
          <xsd:element name="PIN_CODE" nillable="true" type="xsd:string"/>
          <xsd:element name="EXT_REF" nillable="true" type="xsd:string"/>
          <xsd:element name="STORE_ID" nillable="true" type="xsd:string"/>
          <xsd:element name="TERMINAL_ID" nillable="true" type="xsd:string"/>
          <xsd:element name="EMP_ID" nillable="true" type="xsd:string"/>
          <xsd:element name="DATE_INVALIDATED" nillable="true" type="xsd:string"/>
          <xsd:element name="EXPIRY_DATE" nillable="true" type="xsd:string"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="ArrayOfVoucherTransaction"><xsd:sequence>

      </xsd:complexType>
             <xsd:element name="getTransactions" type="tns:getTransactions"/>

I call the webserive with gettransaction with parameter From 01.01.2011 and To 17.01.2011

This is the function look like in delphi 2010

procedure TForm2.Button2Click(Sender: TObject);
var
  rr     : voucher17.getTransactions2;
  getrr    : voucher17.getTransactionsResponse2;
  aa2    : voucher17.ArrayOfVoucherTransaction;
  iinn   : integer;
  test3  : voucher17.VoucherTransaction;
  test4  : voucher17.ArrayOfVoucherTransaction;
begin

rr := getTransactions2.Create;
rr.date_from := '09.01.2011';
rr.date_to   := '10.01.2011';

getrr := GetVoucher_PortType.getTransactions(rr);

// here is the problem but i dont know how to read from the array
 i have try to assign getrr to test3, test4, aa2 but still cant figure out what to do to get the data.

end;

This is the return from soapui so this is working but how can use delphi to read from this?

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

   <SOAP-ENV:Header xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"/>

   <SOAP-ENV:Body>

      <ser-root:getTransactionsResponse xmlns:ser-root="https://webmethods.someurl.com/TopUpServices/webServices/Voucher">

         <voucherTransactions>

            <ArrayOfVoucherTransactionItem>

               <GLOBAL_SERIAL_NUMBER>3132765</GLOBAL_SERIAL_NUMBER>

               <DATE_CREATED>2011-01-17 20:34:49.0</DATE_CREATED>

               <AMOUNT>500</AMOUNT>

               <STATUS>1</STATUS>

               <PIN_CODE>123</PIN_CODE>

               <EXT_REF>772</EXT_REF>

               <STORE_ID>772</STORE_ID>

               <TERMINAL_ID>772</TERMINAL_ID>

               <EMP_ID>772</EMP_ID>

               <DATE_INVALIDATED>2011-01-17 20:34:49.0</DATE_INVALIDATED>

               <EXPIRY_DATE>2011-01-17 20:34:49.0</EXPIRY_DATE>

            </ArrayOfVoucherTransactionItem>

            <ArrayOfVoucherTransactionItem>

               <GLOBAL_SERIAL_NUMBER>3133023</GLOBAL_SERIAL_NUMBER>

               <DATE_CREATED>2011-01-17 20:34:49.0</DATE_CREATED>

               <AMOUNT>500</AMOUNT>

               <STATUS>1</STATUS>

               <PIN_CODE>123</PIN_CODE>

               <EXT_REF>772</EXT_REF>

               <STORE_ID>772</STORE_ID>

               <TERMINAL_ID>772</TERMINAL_ID>

               <EMP_ID>772</EMP_ID>

               <DATE_INVALIDATED>2011-01-17 20:34:49.0</DATE_INVALIDATED>

               <EXPIRY_DATE>2011-01-17 20:34:49.0</EXPIRY_DATE>

            </ArrayOfVoucherTransactionItem>

         </voucherTransactions>

      </ser-root:getTransactionsResponse>

   </SOAP-ENV:Body>

</SOAP-ENV:Envelope>

Here is the proxy

// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described beloow:
// WSDL     : https://webmethods.someurl.com/ws/TopUpServices.webServices:Voucher?WSDL
//  >Import : https://webmethods.someurl.com/ws/TopUpServices.webServices:Voucher?WSDL>0
// Encoding : UTF-8
// Codegen  : [wfAutoDestroyMembers-, wfMapArraysToClasses+, wfProcessHeaders-, wfUseSettersAndGetters+, wfForceSOAP11+, wfForceSOAP12+]
// Version  : 1.0
// (10.1.2011 15:31:05 - - $Rev: 25127 $)
// ************************************************************************ //

unit Voucher17;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns, Dialogs;

const
  IS_OPTN = $0001;
  IS_UNBD = $0002;
  IS_NLBL = $0004;
  IS_UNQL = $0008;

type

  // ************************************************************************ //
  // The following types, referred to in the WSDL document are not being represented
  // in this file. They are either aliases[@] of other types represented or were referred
  // to but never[!] declared in the document. The types from the latter category
  // typically map to predefined/known XML or Embarcadero types; however, they could also
  // indicate incorrect WSDL documents that failed to declare or import a schema type.
  // ************************************************************************ //
  // !:string          - "http://www.w3.org/2001/XMLSchema"[Gbl]

  getTransactions      = class;                 { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[Lit][GblCplx] }
  getTransactionsResponse = class;              { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[Lit][GblCplx] }
  VoucherTransaction   = class;                 { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[GblCplx] }
  getTransactions2     = class;                 { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[Lit][GblElm] }
  getTransactionsResponse2 = class;             { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[Lit][GblElm] }
  ArrayOfVoucherTransaction = class;            { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[GblCplx] }

  // ************************************************************************ //
  // XML       : getTransactions, global, <complexType>
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  getTransactions = class(TRemotable)
  private
    Fdate_from: string;
    Fdate_to: string;
    function  Getdate_from(Index: Integer): string;
    procedure Setdate_from(Index: Integer; const Astring: string);
    function  Getdate_to(Index: Integer): string;
    procedure Setdate_to(Index: Integer; const Astring: string);
  public
    constructor Create; override;
  published
    property date_from: string  Index (IS_NLBL or IS_UNQL) read Getdate_from write Setdate_from;
    property date_to:   string  Index (IS_NLBL or IS_UNQL) read Getdate_to write Setdate_to;
  end;

  // ************************************************************************ //
  // XML       : getTransactionsResponse, global, <complexType>
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  getTransactionsResponse = class(TRemotable)
  private
    FvoucherTransactions: ArrayOfVoucherTransaction;
    function  GetvoucherTransactions(Index: Integer): ArrayOfVoucherTransaction;
    procedure SetvoucherTransactions(Index: Integer; const AArrayOfVoucherTransaction: ArrayOfVoucherTransaction);
  public
    constructor Create; override;
  published
    property voucherTransactions: ArrayOfVoucherTransaction  Index (IS_NLBL or IS_UNQL) read GetvoucherTransactions write SetvoucherTransactions;
  end;

  // ************************************************************************ //
  // XML       : VoucherTransaction, global, <complexType>
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // ************************************************************************ //
  VoucherTransaction = class(TRemotable)
  private
    FGLOBAL_SERIAL_NUMBER: string;
    FDATE_CREATED: string;
    FAMOUNT: string;
    FSTATUS: string;
    FPIN_CODE: string;
    FEXT_REF: string;
    FSTORE_ID: string;
    FTERMINAL_ID: string;
    FEMP_ID: string;
    FDATE_INVALIDATED: string;
    FEXPIRY_DATE: string;
    function  GetGLOBAL_SERIAL_NUMBER(Index: Integer): string;
    procedure SetGLOBAL_SERIAL_NUMBER(Index: Integer; const Astring: string);
    function  GetDATE_CREATED(Index: Integer): string;
    procedure SetDATE_CREATED(Index: Integer; const Astring: string);
    function  GetAMOUNT(Index: Integer): string;
    procedure SetAMOUNT(Index: Integer; const Astring: string);
    function  GetSTATUS(Index: Integer): string;
    procedure SetSTATUS(Index: Integer; const Astring: string);
    function  GetPIN_CODE(Index: Integer): string;
    procedure SetPIN_CODE(Index: Integer; const Astring: string);
    function  GetEXT_REF(Index: Integer): string;
    procedure SetEXT_REF(Index: Integer; const Astring: string);
    function  GetSTORE_ID(Index: Integer): string;
    procedure SetSTORE_ID(Index: Integer; const Astring: string);
    function  GetTERMINAL_ID(Index: Integer): string;
    procedure SetTERMINAL_ID(Index: Integer; const Astring: string);
    function  GetEMP_ID(Index: Integer): string;
    procedure SetEMP_ID(Index: Integer; const Astring: string);
    function  GetDATE_INVALIDATED(Index: Integer): string;
    procedure SetDATE_INVALIDATED(Index: Integer; const Astring: string);
    function  GetEXPIRY_DATE(Index: Integer): string;
    procedure SetEXPIRY_DATE(Index: Integer; const Astring: string);
  published
    property GLOBAL_SERIAL_NUMBER: string  Index (IS_NLBL or IS_UNQL) read GetGLOBAL_SERIAL_NUMBER write SetGLOBAL_SERIAL_NUMBER;
    property DATE_CREATED:         string  Index (IS_NLBL or IS_UNQL) read GetDATE_CREATED write SetDATE_CREATED;
    property AMOUNT:               string  Index (IS_NLBL or IS_UNQL) read GetAMOUNT write SetAMOUNT;
    property STATUS:               string  Index (IS_NLBL or IS_UNQL) read GetSTATUS write SetSTATUS;
    property PIN_CODE:             string  Index (IS_NLBL or IS_UNQL) read GetPIN_CODE write SetPIN_CODE;
    property EXT_REF:              string  Index (IS_NLBL or IS_UNQL) read GetEXT_REF write SetEXT_REF;
    property STORE_ID:             string  Index (IS_NLBL or IS_UNQL) read GetSTORE_ID write SetSTORE_ID;
    property TERMINAL_ID:          string  Index (IS_NLBL or IS_UNQL) read GetTERMINAL_ID write SetTERMINAL_ID;
    property EMP_ID:               string  Index (IS_NLBL or IS_UNQL) read GetEMP_ID write SetEMP_ID;
    property DATE_INVALIDATED:     string  Index (IS_NLBL or IS_UNQL) read GetDATE_INVALIDATED write SetDATE_INVALIDATED;
    property EXPIRY_DATE:          string  Index (IS_NLBL or IS_UNQL) read GetEXPIRY_DATE write SetEXPIRY_DATE;
  end;

  // ************************************************************************ //
  // XML       : getTransactions, global, <element>
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // Info      : Wrapper
  // ************************************************************************ //
  getTransactions2 = class(getTransactions)
  private
  published
  end;

  // ************************************************************************ //
  // XML       : getTransactionsResponse, global, <element>
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // Info      : Wrapper
  // ************************************************************************ //
  getTransactionsResponse2 = class(getTransactionsResponse)
  private
  published
  end;

  Array_Of_VoucherTransaction = array of VoucherTransaction;   { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[GblUbnd] }

  // ************************************************************************ //
  // XML       : ArrayOfVoucherTransaction, global, <complexType>
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // ************************************************************************ //
  ArrayOfVoucherTransaction = class(TRemotable)
  private
    FArrayOfVoucherTransactionItem: Array_Of_VoucherTransaction;
    function  GetArrayOfVoucherTransactionItem(Index: Integer): Array_Of_VoucherTransaction;
    procedure SetArrayOfVoucherTransactionItem(Index: Integer; const AArray_Of_VoucherTransaction: Array_Of_VoucherTransaction);
  public
    function   GetVoucherTransactionArray(Index: Integer): VoucherTransaction;
    procedure  SetVoucherTransactionArray(Index: Integer; const Item: VoucherTransaction);
    function   GetVoucherTransactionArrayLength: Integer;
    procedure  SetVoucherTransactionArrayLength(Len: Integer);

    property   VoucherTransactionArray[Index: Integer]: VoucherTransaction read GetVoucherTransactionArray write SetVoucherTransactionArray; default;
    property   Len: Integer read GetVoucherTransactionArrayLength write SetVoucherTransactionArrayLength;
  published
    property ArrayOfVoucherTransactionItem: Array_Of_VoucherTransaction  Index (IS_UNBD or IS_UNQL) read GetArrayOfVoucherTransactionItem write SetArrayOfVoucherTransactionItem;
  end;

  // ************************************************************************ //
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // soapAction: TopUpServices_webServices_Voucher_Binder_%operationName%
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : document
  // binding   : TopUpServices_webServices_Voucher_Binder
  // service   : Voucher
  // port      : TopUpServices_webServices_Voucher_Port
  // URL       : https://webmethods.someurl.com:443/ws/TopUpServices.webServices:Voucher
  // ************************************************************************ //
  Voucher_PortType = interface(IInvokable)
  ['{DCE754E5-4B05-3C9B-8078-D4C2BB3F12B4}']

    // Cannot unwrap:
    //     - Input element wrapper name does not match operation's name
    //     - More than one strictly out element was found
     function  getTransactions(const parameters: getTransactions2): getTransactionsResponse2; stdcall;

   end;

function GetVoucher_PortType(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): Voucher_PortType;

implementation
  uses SysUtils;

function GetVoucher_PortType(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): Voucher_PortType;
const
  defWSDL = 'https://webmethods.someurl.com/ws/TopUpServices.webServices:Voucher?WSDL';
  defURL  = 'https://webmethods.someurl.com:443/ws/TopUpServices.webServices:Voucher';
  defSvc  = 'Voucher';
  defPrt  = 'TopUpServices_webServices_Voucher_Port';
var
  RIO: THTTPRIO;
begin
  Result := nil;
  if (Addr = '') then
  begin
    if UseWSDL then
      Addr := defWSDL
    else
      Addr := defURL;
  end;
  if HTTPRIO = nil then
    RIO := THTTPRIO.Create(nil)
  else
    RIO := HTTPRIO;
  try
    Result := (RIO as Voucher_PortType);
    if UseWSDL then
    begin
      RIO.WSDLLocation := Addr;
      RIO.Service := defSvc;
      RIO.Port := defPrt;
    end else
      RIO.URL := Addr;
  finally
    if (Result = nil) and (HTTPRIO = nil) then
      RIO.Free;
  end;
end;

constructor getTransactions.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

function getTransactions.Getdate_from(Index: Integer): string;
begin
  Result := Fdate_from;
end;

procedure getTransactions.Setdate_from(Index: Integer; const Astring: string);
begin
  Fdate_from := Astring;
end;

function getTransactions.Getdate_to(Index: Integer): string;
begin
  Result := Fdate_to;
end;

procedure getTransactions.Setdate_to(Index: Integer; const Astring: string);
begin
  Fdate_to := Astring;
end;

constructor getTransactionsResponse.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

function getTransactionsResponse.GetvoucherTransactions(Index: Integer): ArrayOfVoucherTransaction;
begin
  Result := FvoucherTransactions;
end;

procedure getTransactionsResponse.SetvoucherTransactions(Index: Integer; const AArrayOfVoucherTransaction: ArrayOfVoucherTransaction);
begin
  FvoucherTransactions := AArrayOfVoucherTransaction;
end;

function VoucherTransaction.GetGLOBAL_SERIAL_NUMBER(Index: Integer): string;
begin
  Result := FGLOBAL_SERIAL_NUMBER;
end;

procedure VoucherTransaction.SetGLOBAL_SERIAL_NUMBER(Index: Integer; const Astring: string);
begin
  FGLOBAL_SERIAL_NUMBER := Astring;
end;

function VoucherTransaction.GetDATE_CREATED(Index: Integer): string;
begin
  Result := FDATE_CREATED;
end;

procedure VoucherTransaction.SetDATE_CREATED(Index: Integer; const Astring: string);
begin
  FDATE_CREATED := Astring;
end;

function VoucherTransaction.GetAMOUNT(Index: Integer): string;
begin
  Result := FAMOUNT;
end;

procedure VoucherTransaction.SetAMOUNT(Index: Integer; const Astring: string);
begin
  FAMOUNT := Astring;
end;

function VoucherTransaction.GetSTATUS(Index: Integer): string;
begin
  Result := FSTATUS;
end;

procedure VoucherTransaction.SetSTATUS(Index: Integer; const Astring: string);
begin
  FSTATUS := Astring;
end;

function VoucherTransaction.GetPIN_CODE(Index: Integer): string;
begin
  Result := FPIN_CODE;
end;

procedure VoucherTransaction.SetPIN_CODE(Index: Integer; const Astring: string);
begin
  FPIN_CODE := Astring;
end;

function VoucherTransaction.GetEXT_REF(Index: Integer): string;
begin
  Result := FEXT_REF;
end;

procedure VoucherTransaction.SetEXT_REF(Index: Integer; const Astring: string);
begin
  FEXT_REF := Astring;
end;

function VoucherTransaction.GetSTORE_ID(Index: Integer): string;
begin
  Result := FSTORE_ID;
end;

procedure VoucherTransaction.SetSTORE_ID(Index: Integer; const Astring: string);
begin
  FSTORE_ID := Astring;
end;

function VoucherTransaction.GetTERMINAL_ID(Index: Integer): string;
begin
  Result := FTERMINAL_ID;
end;

procedure VoucherTransaction.SetTERMINAL_ID(Index: Integer; const Astring: string);
begin
  FTERMINAL_ID := Astring;
end;

function VoucherTransaction.GetEMP_ID(Index: Integer): string;
begin
  Result := FEMP_ID;
end;

procedure VoucherTransaction.SetEMP_ID(Index: Integer; const Astring: string);
begin
  FEMP_ID := Astring;
end;

function VoucherTransaction.GetDATE_INVALIDATED(Index: Integer): string;
begin
  Result := FDATE_INVALIDATED;
end;

procedure VoucherTransaction.SetDATE_INVALIDATED(Index: Integer; const Astring: string);
begin
  FDATE_INVALIDATED := Astring;
end;

function VoucherTransaction.GetEXPIRY_DATE(Index: Integer): string;
begin
  Result := FEXPIRY_DATE;
end;

procedure VoucherTransaction.SetEXPIRY_DATE(Index: Integer; const Astring: string);
begin
  FEXPIRY_DATE := Astring;
end;

function ArrayOfVoucherTransaction.GetVoucherTransactionArray(Index: Integer): VoucherTransaction;
begin
  Result := FArrayOfVoucherTransactionItem[Index];
end;

procedure ArrayOfVoucherTransaction.SetVoucherTransactionArray(Index: Integer; const Item: VoucherTransaction);
begin
   FArrayOfVoucherTransactionItem[Index] := Item;
end;

function ArrayOfVoucherTransaction.GetVoucherTransactionArrayLength: Integer;
begin
  if Assigned(FArrayOfVoucherTransactionItem) then
    Result := System.Length(FArrayOfVoucherTransactionItem)
  else
    Result := 0;
end;

procedure ArrayOfVoucherTransaction.SetVoucherTransactionArrayLength(Len: Integer);
begin
  System.SetLength(FArrayOfVoucherTransactionItem, Len);
end;

function ArrayOfVoucherTransaction.GetArrayOfVoucherTransactionItem(Index: Integer): Array_Of_VoucherTransaction;
begin
  Result := FArrayOfVoucherTransactionItem;
end;

procedure ArrayOfVoucherTransaction.SetArrayOfVoucherTransactionItem(Index: Integer; const AArray_Of_VoucherTransaction: Array_Of_VoucherTransaction);
begin
  FArrayOfVoucherTransactionItem := AArray_Of_VoucherTransaction;
end;

initialization
  InvRegistry.RegisterInterface(TypeInfo(Voucher_PortType), 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'UTF-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(Voucher_PortType), 'TopUpServices_webServices_Voucher_Binder_%operationName%');
  InvRegistry.RegisterInvokeOptions(TypeInfo(Voucher_PortType), ioDocument);
  InvRegistry.RegisterInvokeOptions(TypeInfo(Voucher_PortType), ioLiteral);
  InvRegistry.RegisterInvokeOptions(TypeInfo(Voucher_PortType), ioSOAP12);
  InvRegistry.RegisterExternalParamName(TypeInfo(Voucher_PortType), 'invalidateVoucher', 'parameters1', 'parameters');
  InvRegistry.RegisterExternalParamName(TypeInfo(Voucher_PortType), 'getTransactions', 'parameters1', 'parameters');
  InvRegistry.RegisterExternalParamName(TypeInfo(Voucher_PortType), 'createVoucher', 'parameters1', 'parameters');
  RemClassRegistry.RegisterXSClass(getTransactions, 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'getTransactions');
  RemClassRegistry.RegisterSerializeOptions(getTransactions, [xoLiteralParam]);
  RemClassRegistry.RegisterXSClass(getTransactionsResponse, 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'getTransactionsResponse');
  RemClassRegistry.RegisterSerializeOptions(getTransactionsResponse, [xoLiteralParam]);
  RemClassRegistry.RegisterXSClass(VoucherTransaction, 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'VoucherTransaction');
  RemClassRegistry.RegisterXSClass(getTransactions2, 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'getTransactions2', 'getTransactions');
  RemClassRegistry.RegisterXSClass(getTransactionsResponse2, 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'getTransactionsResponse2', 'getTransactionsResponse');
  RemClassRegistry.RegisterXSInfo(TypeInfo(Array_Of_VoucherTransaction), 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'Array_Of_VoucherTransaction');
  RemClassRegistry.RegisterXSClass(ArrayOfVoucherTransaction, 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'ArrayOfVoucherTransaction');

end.

Body:
Although I don't particular like the MapArraysToClasses option enabled, the following illustrates how to access the data sent back by the service with the proxy you've generated:

procedure TForm33.Button1Click(Sender: TObject);
var
  rr     : voucher17.getTransactions2;
  getrr    : voucher17.getTransactionsResponse2;
  I: Integer;
begin
  rr := getTransactions2.Create;
  try
    rr.date_from := '09.01.2011';
    rr.date_to   := '10.01.2011';

    getrr := GetVoucher_PortType.getTransactions(rr);
    try
      if Assigned(getrr.voucherTransactions) then
      begin
        for I := 0 to getrr.voucherTransactions.Len-1 do
        begin
          ShowMessage(Format('%s, %s, %s', [
              getrr.voucherTransactions[I].GLOBAL_SERIAL_NUMBER,
              getrr.voucherTransactions[I].DATE_CREATED,
              getrr.voucherTransactions[I].AMOUNT]));
        end;
      end;
    finally
      getrr.Free;
    end;
  finally
    rr.Free;
  end;
end;

I'm opting to display the values of three of the fields. You'll probably want to read the other fields as well.

I don't like the fact that AutoDestroyMembers was disabled because even though the code above cleans up the request and response objects, the array of objects contained in the response will not be cleaned up properly:(.

Cheers,

Bruneau


问:
What is yarn.lock and expo in react native?
I am new in React native development. I didn't find what Yarn is for and how it works in React native.

答: Yarn is dependency management software, that means if u need any third party library for ur react native app like networking library or new component, then u can install it using yarn, and expo on the other hand is client for the react native bundler server, it can run the app on ur device while developing.you can Install expo from play store or app store</p>


问:
How to remove dictionary[String:AnyObject] for array using filter function in swift?
```<code>var globalCountArray = [AnyObject]()
var assetDictionary = [String:AnyObject]()
globalCountArray.append(assetDictionary as AnyObject)
</code>```

How to filter dictionary  using Anyobject array? I have tried this.

```<code>  globalCountArray = globalCountArray.filter {$0     as AnyObject != dict }
</code>```

But I got error

Binary operator '!=' cannot be applied to operands of type 'AnyObject' and '[String : AnyObject]'"

答:
You can write an extension for Dictionary:

```<code>extension Dictionary where Key: ExpressibleByStringLiteral, Value: AnyObject {
    func isEqual(_ dictionary: [String: AnyObject]) -> Bool {
        return NSDictionary(dictionary: dictionary).isEqual(to: self)
    }

    func isNotEqual(_ dictionary: [String: AnyObject]) -> Bool {
        return !NSDictionary(dictionary: dictionary).isEqual(to: self)
    }
}
</code>```

Then you can compare [String: AnyObject] dictionaries with:

```<code>FirstDictionary.isEqual(SecondDictionary)
FirstDictionary.isNotEqual(SecondDictionary)
</code>```

In your case:

```<code>var globalCountArray = [AnyObject]()
var assetDictionary = [String:AnyObject]()
globalCountArray.append(assetDictionary as AnyObject)

globalCountArray = globalCountArray.filter { (($0 as! [String: AnyObject]).isNotEqual(assetDictionary)) }
</code>```

Body:
var globalCountArray = [AnyObject]()
var assetDictionary = [String:AnyObject]()
globalCountArray.append(assetDictionary as AnyObject)

How to filter dictionary  using Anyobject array? I have tried this.

  globalCountArray = globalCountArray.filter {$0     as AnyObject != dict }

But I got error

Binary operator '!=' cannot be applied to operands of type 'AnyObject' and '[String : AnyObject]'"

Body:
You can write an extension for Dictionary:

extension Dictionary where Key: ExpressibleByStringLiteral, Value: AnyObject {
    func isEqual(_ dictionary: [String: AnyObject]) -> Bool {
        return NSDictionary(dictionary: dictionary).isEqual(to: self)
    }

    func isNotEqual(_ dictionary: [String: AnyObject]) -> Bool {
        return !NSDictionary(dictionary: dictionary).isEqual(to: self)
    }
}

Then you can compare [String: AnyObject] dictionaries with:

FirstDictionary.isEqual(SecondDictionary)
FirstDictionary.isNotEqual(SecondDictionary)

In your case:

var globalCountArray = [AnyObject]()
var assetDictionary = [String:AnyObject]()
globalCountArray.append(assetDictionary as AnyObject)

globalCountArray = globalCountArray.filter { (($0 as! [String: AnyObject]).isNotEqual(assetDictionary)) }


问:
Get the customer user_id in Woocommerce email footer template
I am trying to get current_user_id in woocommerce custom email template but it returns 0. Does anyone know how to get user_id in email template in wordpress. I get the user id when I use this code in any php template.

Below is my code:

```<code><?php global $current_user;
      get_currentuserinfo();
      echo '<h4>Your code:</h3>' . $current_user->ID . '';
?>
</code>```

Here is complete template code link:
email-template-code

答:
You can't get the current user in woocommerce email templates, but you can get the customer user ID from the Order.

To get the customer User ID, you can set and get some data in the $GLOBAL variable:

Set the data - On your active theme function.php file:

add_action( 'woocommerce_email_header', 'wc_email_user_id', 10, 2 );
function wc_email_user_id( $email_heading, $email ) {
    // Set global variable data: user ID and Order ID
    $GLOBALS['emails_custom_data'] = array(
        'user_id' => get_post_meta( $email->object->ID, '_customer_user', true ), // Set the user ID
        'order_id' => $email->object->ID, // Set the Order ID
    );
}
```

<ul>
<li><strong>Get the data</strong> - On your template file just after:</li>
</ul>

<pre class="lang-php prettyprint-override"><code>if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}

## --- Your custom Code start here --- ##

$refNameGlobalsVar = $GLOBALS; // Get the data
$custom_data = $refNameGlobalsVar['emails_custom_data']; // Set the data in a variable

$user_id = $custom_data['user_id']; // Get the user ID
$order_id = $custom_data['order_id']; // Get the order ID (in case of…)

// Testing output
echo '<p>The user ID is '.$user_id.' | From the Order ID: '.$order_id.'</p>';

## --- End of custom code --- ##

?>
</code>```

This code is tested and works

Body:
I am trying to get current_user_id in woocommerce custom email template but it returns 0. Does anyone know how to get user_id in email template in wordpress. I get the user id when I use this code in any php template.

Below is my code:

<?php global $current_user;
      get_currentuserinfo();
      echo '
Your code:
' . $current_user->ID . '';
?>

Here is complete template code link:
email-template-code

Body:
You can't get the current user in woocommerce email templates, but you can get the customer user ID from the Order.

To get the customer User ID, you can set and get some data in the $GLOBAL variable:

Set the data - On your active theme function.php file:

add_action( 'woocommerce_email_header', 'wc_email_user_id', 10, 2 );
function wc_email_user_id( $email_heading, $email ) {
    // Set global variable data: user ID and Order ID
    $GLOBALS['emails_custom_data'] = array(
        'user_id' => get_post_meta( $email->object->ID, '_customer_user', true ), // Set the user ID
        'order_id' => $email->object->ID, // Set the Order ID
    );
}

Get the data - On your template file just after:

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}

## --- Your custom Code start here --- ##

$refNameGlobalsVar = $GLOBALS; // Get the data
$custom_data = $refNameGlobalsVar['emails_custom_data']; // Set the data in a variable

$user_id = $custom_data['user_id']; // Get the user ID
$order_id = $custom_data['order_id']; // Get the order ID (in case of…)

// Testing output
echo '<p>The user ID is '.$user_id.' | From the Order ID: '.$order_id.'</p>';

## --- End of custom code --- ##

?>

This code is tested and works


问:
BitsTransfer , percentage output
I want to display the download status in percent.

I use a bitjob for my task.

Method invocation failed because [System.Object[]] does not contain a
  method named 'op_Division'.
      At C:\Users\administrator\Desktop\test.ps1:56 char:8
      +        $per=$CopyMyBackups.BytesTransferred/$CopyMyBackups.BytesTotal ...
      +        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (op_Division:String) [], RuntimeException
          + FullyQualifiedErrorId : MethodNotFound
        You cannot call a method on a null-valued expression.
      At C:\Users\administrator\Desktop\test.ps1:57 char:8
      +        Write-Progress -activity "Copying" -status ($per.ToString()+"% ...
      +        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
          + FullyQualifiedErrorId : InvokeMethodOnNull

My script is below:

```<code> }

$BitJobs=Import-Csv "$ScriptPath\$CSVListName" | Start-BitsTransfer -Asynchronous -Priority Normal -DisplayName CopyMyBackups

    while ($CopyMyBackups | ?{ $_.JobState -ne "Transferred"})
    {
       #  this
       $per=$CopyMyBackups.BytesTransferred/$CopyMyBackups.BytesTotal*100
       Write-Progress -activity "Copying" -status ($per.ToString()+"%") -PercentComplete $per

      #$CopyMyBackups = Get-BitsTransfer| ?{ $_.DisplayName -eq "CopyMyBackups"}

       Start-Sleep 10
}  }
$CopyMyBackups| Complete-BitsTransfer
</code>```

答:
My guess is that you start several jobs from CSV, which means that when you try to get BytesTransferred property, PowerShell returns an array ([System.Object[]]).

You need to iterate over $CopyMyBackups or get total of BytesTransferred/BytesTotal using something like

```<code>($CopyMyBackups.BytesTransferred | Measure-Object -Sum).Sum
</code>```

Title: BitsTransfer , percentage output

Body:
I want to display the download status in percent.

I use a bitjob for my task.

Method invocation failed because [System.Object[]] does not contain a
  method named 'op_Division'.
      At C:\Users\administrator\Desktop\test.ps1:56 char:8
      +        $per=$CopyMyBackups.BytesTransferred/$CopyMyBackups.BytesTotal ...
      +        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (op_Division:String) [], RuntimeException
          + FullyQualifiedErrorId : MethodNotFound
        You cannot call a method on a null-valued expression.
      At C:\Users\administrator\Desktop\test.ps1:57 char:8
      +        Write-Progress -activity "Copying" -status ($per.ToString()+"% ...
      +        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
          + FullyQualifiedErrorId : InvokeMethodOnNull

My script is below:

 }

$BitJobs=Import-Csv "$ScriptPath\$CSVListName" | Start-BitsTransfer -Asynchronous -Priority Normal -DisplayName CopyMyBackups

    while ($CopyMyBackups | ?{ $_.JobState -ne "Transferred"})
    {
       #  this
       $per=$CopyMyBackups.BytesTransferred/$CopyMyBackups.BytesTotal*100
       Write-Progress -activity "Copying" -status ($per.ToString()+"%") -PercentComplete $per

      #$CopyMyBackups = Get-BitsTransfer| ?{ $_.DisplayName -eq "CopyMyBackups"}

       Start-Sleep 10
}  }
$CopyMyBackups| Complete-BitsTransfer

Body:
My guess is that you start several jobs from CSV, which means that when you try to get BytesTransferred property, PowerShell returns an array ([System.Object[]]).

You need to iterate over $CopyMyBackups or get total of BytesTransferred/BytesTotal using something like

($CopyMyBackups.BytesTransferred | Measure-Object -Sum).Sum


问:
How to calculate date from no. of months span in MySQL?
I have 1 date column date=2017-01-01 and I have no_of_months column having values like 20,30,50 etc.

Now, our date is 1 Jan 17, after adding 20 months I will have outputDate=1 Oct 2018

How to get outputDate as result?

答:
Use function DATE_ADD

```<code>SELECT DATE_ADD(dateColumn, INTERVAL no_of_months MONTH) outputDate
</code>```

in plain text as syntax

```<code> SELECT DATE_ADD(DATE('2017-01-01'), INTERVAL 20 MONTH) outputDate
</code>```

Body:
Use function DATE_ADD

SELECT DATE_ADD(dateColumn, INTERVAL no_of_months MONTH) outputDate

in plain text as syntax

 SELECT DATE_ADD(DATE('2017-01-01'), INTERVAL 20 MONTH) outputDate


问:
Java Swing: cannot set JTextArea text in JDialog after it opens
I have a JTable where the last column is a JButton whose ActionListener is:

```<code>private class EventDetailActionListener implements ActionListener {

    @Override
    public void actionPerformed(ActionEvent e) {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                final long seqEventSel = tblModelEvents.getEventSeq(tblEvents.getSelectedRow());
                final String eventDetail = tblModelEvents.getEventDetail(tblEvents.getSelectedRow());
                new DialogEventDetail(seqEventSel).setDetailText(eventDetail);
            }
        });
    }
}
</code>```

and the class for JDialog is:

```<code>public class DialogEventDetail extends JDialog {
    private JTextArea txtAreaDetail;

    public DialogEventDetail(JFrame parent) {
      /* Building JDialog with its size and a BorderLayout
         with a JScrollPanel at CENTER containing a
         txtAreaDetail */
      this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
      this.setVisible(true);
    }

    public void setDetailText(String text) {
      this.txtAreaDetail.setText(text);
    }
}
</code>```

This JDialog is used to show a long XML text which is held by TableModel but not immediately visible to suer when JTable loads.
JTextArea is not enabled to be edited by user but I cannot understand why it is always empty after JDialog appears.
There's no text showed inside. Instead, if I call

```<code>this.txtAreaDetail.setText(text);
</code>```

inside the constructor, the text appears.
Why this?

答:
Try using

```<code>this.txtAreaDetail.revalidate();
this.txtAreaDetail.repaint();
</code>```

Any specific reason using EventQueue over SwingWorker.

As I can not add comments posting this as answer.

Body:
I have a JTable where the last column is a JButton whose ActionListener is:

private class EventDetailActionListener implements ActionListener {

    @Override
    public void actionPerformed(ActionEvent e) {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                final long seqEventSel = tblModelEvents.getEventSeq(tblEvents.getSelectedRow());
                final String eventDetail = tblModelEvents.getEventDetail(tblEvents.getSelectedRow());
                new DialogEventDetail(seqEventSel).setDetailText(eventDetail);
            }
        });
    }
}

and the class for JDialog is:

public class DialogEventDetail extends JDialog {
    private JTextArea txtAreaDetail;

    public DialogEventDetail(JFrame parent) {
      /* Building JDialog with its size and a BorderLayout
         with a JScrollPanel at CENTER containing a
         txtAreaDetail */
      this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
      this.setVisible(true);
    }

    public void setDetailText(String text) {
      this.txtAreaDetail.setText(text);
    }
}

This JDialog is used to show a long XML text which is held by TableModel but not immediately visible to suer when JTable loads.
JTextArea is not enabled to be edited by user but I cannot understand why it is always empty after JDialog appears.
There's no text showed inside. Instead, if I call

this.txtAreaDetail.setText(text);

inside the constructor, the text appears.
Why this?

Body:
Try using

this.txtAreaDetail.revalidate();
this.txtAreaDetail.repaint();

Any specific reason using EventQueue over SwingWorker.

As I can not add comments posting this as answer.


问:
JIRA: to close or to resolve?
You can reopen both a resolved and a closed issue in JIRA. What's the practical difference? (besides requiring different permissions to resolve/close issues e.g. if QA is involved)

We have some differences of opinion in our team for whether to resolve or close, and I'd like to point towards some authority and say "we should do it this way".

答:
Resolved is usually "Ready for Testing"

Closed is usually "It worked"

You may also want to see this blog post for more details about how JIRA uses the Resolved/Closed states and the system Resolution field.

Title: JIRA: to close or to resolve?


问:
Powershell to fetch software's license key?
I am trying to fetch details about Softwares that are installed on my machine using Powershell. I am able to get all the details I need using the below mentioned command:

```<code>$details = get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*
</code>```

However, as a part of new requirement I would also like to get software's license key. I see there are Softwares who are able to fetch license key for any installed software, but still not sure how to get any Software's license key using Powershell.
I tried this but the results are not what I want:

```<code>(Get-WmiObject -query ‘select * from SoftwareLicensingService’)
</code>```

Any leads will be helpful.

答:
There is no single mechanism to store license information in Windows. As such, every application rolls their own. Some store it in files, some in the registry, some in more obscure ways.

Not even the details of what is license information (a key? a name/password pair? A guid? An encryption secret?) is uniform across applications.

So there is no way to read license information. If you found a software that "does it", it just means they implemented a huge list of programs, licence information and ways to find them on a windows machine.

Body:
I am trying to fetch details about Softwares that are installed on my machine using Powershell. I am able to get all the details I need using the below mentioned command:

$details = get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*

However, as a part of new requirement I would also like to get software's license key. I see there are Softwares who are able to fetch license key for any installed software, but still not sure how to get any Software's license key using Powershell.
I tried this but the results are not what I want:

(Get-WmiObject -query ‘select * from SoftwareLicensingService’)

Any leads will be helpful.


问:
iReport line chart category label
i'm using the Line Chart component to generate a chart based on the consumption of a building.
Imagine a possible chart based on the consumption of a building in a period of a month and a resolution of a day. It will have 30 points of consumption corresponding to 30 days.
The problem is with the category axis labels. With a considerable amount of points, the labels becomes unreadable. How can i just label some points?

My best regards

答:
Use this code to generate a label on the line chart in JASPER report</p>

```<code>else if(jasperChart.getChartType() == JRChart.CHART_TYPE_LINE) {
    LineAndShapeRenderer line = (LineAndShapeRenderer) chart.getCategoryPlot().getRenderer();
    line.setBaseItemLabelsVisible(Boolean.TRUE);
    line.setBaseItemLabelGenerator((CategoryItemLabelGenerator) new StandardCategoryItemLabelGenerator());
}
</code>```

Title: iReport line chart category label

Body:
Use this code to generate a label on the line chart in JASPER report

else if(jasperChart.getChartType() == JRChart.CHART_TYPE_LINE) {
    LineAndShapeRenderer line = (LineAndShapeRenderer) chart.getCategoryPlot().getRenderer();
    line.setBaseItemLabelsVisible(Boolean.TRUE);
    line.setBaseItemLabelGenerator((CategoryItemLabelGenerator) new StandardCategoryItemLabelGenerator());
}


问:
Are there security risks to whitelisting all the column names in a model with strong params?
I'm in the process of extracting some parts of a project into an engine and I wanted to whitelist user params in such a way that the user doesn't have to configure anything.

This is what I ultimately came up with:

```<code>def user_params
  params.permit(::User.columns.map(&:name), :current_password, :password, :password_confirmation)
end
</code>```

It works so far (it allows all attributes in the user model and seems to reject anything else), however, I can't find another implementation of this in my searching that does it the same way and I'm wondering if that's because there's something I'm not seeing.

Is there a security vulnerability with setting strong params up like this?

答:
You can use permit! method. See Rails API doc

This can be used to pass mass assignment

Body:
I'm in the process of extracting some parts of a project into an engine and I wanted to whitelist user params in such a way that the user doesn't have to configure anything.

This is what I ultimately came up with:

def user_params
  params.permit(::User.columns.map(&:name), :current_password, :password, :password_confirmation)
end

It works so far (it allows all attributes in the user model and seems to reject anything else), however, I can't find another implementation of this in my searching that does it the same way and I'm wondering if that's because there's something I'm not seeing.

Is there a security vulnerability with setting strong params up like this?