Reputation: 1226
I have a java program that contains a username and passwords (strings) and an ArrayList of objects with 4 attributes (long, int, int int) and I want to pass these 3 things to a WebService (that I have yet to make). My host is Bluehost and it's a shared server so I won't have Java available server side it will need to be in PHP.
What is the best way of connecting to the webservice and passing this into php?
EDIT.
OK so I now have something like this:
public void upload(ArrayList<MyObject> myList) throws Exception{
//HTTP POST Service
try{
HttpClient httpclient = HttpClientBuilder.create().build();
URI uri = new URIBuilder()
.setScheme("http")
.setHost("www.myHost.com")
.setPath("/myWebservice.php")
.setUserInfo(userID, password)
.build();
HttpPost httppost = new HttpPost(uri);
httpclient.execute(httppost);
}catch (Exception e) {
e.printStackTrace();
}
}
But I'm still not sure how I can pass the ArrayList in a way that I'll be able to receive and split it into it's components on the PHP side?
Upvotes: 0
Views: 740
Reputation: 39477
You can use an HTTP client e.g. this one.
http://hc.apache.org/httpcomponents-client-ga/tutorial/html/index.html
and send a GET/POST request to your WebService.
Upvotes: 1