views:

69

answers:

1

Hi Guys,

i'm facing a little problem and can't find a solution. The situation:

  • I have a Java-Webservice containing different Methods. One of these creates a new Object (named "Bestellung", which is german for "Order"). This object contains some attributes, most of them are Strings, one is a Hashmap named "applikationsDaten" (application data).
  • I'm receiving this object in php via SoapClient - all attributes are filled as i want them. print_r() shows the following (shortened to the relevant parts):
    stdClass Object (
      [enthMWsT] => 0
      [preisStreckeGesamt] => 28.6
      [waehrung] => EUR
      [applikationsDaten] => stdClass Object (
      [entry] => Array (
        [0] => Array ( [key] => test [value] => 1 )
        [1] => Array ( [key] => fahrDrucken [value] => 1 )
        [2] => Array ( [key] => fahrLfdnr [value] => 0 )
      )
    )
  • after manipulation some of the attributes (but not the application data) i'm trying to send that object back to my webservice which should check some things and save the Order to the Database. This is where the problem appears: all attributes are received perfectly, but the application data isn't. When i'm trying to System.out.print() it, i get the following:
[STDOUT] {[key: null]=[value: null], [key: null]=[value: null], [key: null]=[value: null]}

as you can see, it's the number of elements is correct, but all keys an values are null.

my problem is: why don't i get the correct keys/values on java-side?

PS: if you need more information to analyse this, please don't hesitate to ask

EDIT:

on java-side i'm running a jBoss 4.2.2GA

on PHP-side i use the SoapClient Object like this:

$conf['soap_wsdl'] = "http://192.168.0.213:8180/R1WebService/Service?wsdl";
$conf['soap_timeout'] = 5;

$soap = new SoapClient($conf['soap_wsdl'], array('connection_timeout' => $conf['soap_timeout']));

$bst = $soap->getBestellung()->return;

// some stuff

$return = $soap->saveBestellung(array($bst))->return;
+1  A: 

i found the solution: the problem was in my java code. it's not enough to declare the hashmap in the object like this:

private HashMap applikationsDaten;

public HashMap getApplikationsDaten() {
    return applikationsDaten;
}

public void setApplikationsDaten(HashMap applikationsDaten) {
    this.applikationsDaten = applikationsDaten;
}

to make it work, i had to specify datatypes for the Hashmap like this:

private HashMap<String,String> applikationsDaten;

public HashMap<String,String> getApplikationsDaten() {
    return applikationsDaten;
}

public void setApplikationsDaten(HashMap<String,String> applikationsDaten) {
    this.applikationsDaten = applikationsDaten;
}

after changing this and redeploying the webservice it worked as expected. I'll leave this question and mark it as community wiki instead of deleting it - maybe it helps someone looking for the same failure.

PS: thanks to ZeissS for his hints.

oezi