Sending a HashMap parameter to a web service from PHP

Actually, the problem is NOT how to do it, but if it is a design error. I am worried because I read a lot about using only standard data types in WS. However, I had no problem implementing a package that receives a HashMap and populates this parameter with PHP using nuSoap.

I have a ParameterBean class with these members (e.g. getters and seters) that includes a HashMap.

private int ID; private String value; private String name; private HashMap<Integer, String> map = new HashMap<Integer, String>(); 

And a service that gets an instance from this class. Then from the PHP client, I call:

 $map = array(1 => 'Foo', 2 => 'Bar'); $paramsp = array( 'ID' => '1', 'value' => 'Some Value', 'name' => 'A Name', 'map' => $map ); $params = array($paramsp); $resp = $client->call('test',$params); print_r($client->response); 

It works like a charm! Question: Is it frowning? Will this lead to a headache in the future in some way?

+4
source share
1 answer

A HashMap is a standard data type of type dang and presents no problems when used in a web service.

As you have seen, PHP and Java do not have hash map issues. JSON supports them (although they are called "objects" and do not have explicit Java input).

Although truly esoteric data types can cause problems for web services that are expected to interact widely, hash maps are not included in this category and should be used without problems.

+1
source

All Articles