Jump to content

jonoc33

Members
  • Posts

    151
  • Joined

  • Last visited

    Never

Everything posted by jonoc33

  1. Hey guys! Haven't been here in a while but it's finally time I need help again. Heres the issue i'm having: I'm working for my Dad, making a new application called Traveller. They use web services to input data and get data. Web services so far have worked well for me. They output data perfectly and it's all worked fine. Now i'm up to the stage where I need to input data to a web service so that it can create a record. It uses ALOT of data. I'm talking: Notice how theres nested data or objects in there? Look at address_det, theres multiple address_details in that. At the moment it passes through all values fine, except for these nested objects. What i'm struggling with is being able to input multiple address detail objects inside address_det. Considering each object would have the same name its a bit hard to code that. Heres what i've got at the moment. $parameters = new Request(); $parameters->user_id = $_COOKIE['user_id']; $parameters->password = $_COOKIE['password']; $parameters->req_input = new ReqInput(); $parameters->req_input->request_id = 0; $parameters->req_input->request_description = $issue; $parameters->req_input->refer_no = $refno; $parameters->req_input->service_type = $service; $parameters->req_input->request_type = $request; $parameters->req_input->function_type = $function; $parameters->req_input->request_datetime = date("Y-m-d") . "T" . date("H:i:s"); $parameters->req_input->due_datetime = date("Y-m-d") . "T" . date("H:i:s"); $parameters->req_input->centre = 'WEB'; $parameters->req_input->how_received = 'WEB'; $parameters->req_input->input_by = $_COOKIE['responsible_code']; $customer_name_det = array( "name_id" => 0, "pref_title" => $cust_title, "given_names" => $cust_given, "surname" => $cust_surname, "mobile_no" => $cust_mobile, "telephone" => $cust_phone, "work_no" => $cust_work, "email_address" => $cust_email, "name_ctr" => 0, "company_name" => $cust_company ); $address_det = array( array( "address_id" => 0, "house_number" => $cust_address_number, "property_number" => $cust_address_fnumber, "street_name" => $cust_address_street, "street_type" => $cust_address_streettype, "locality" => $cust_address_suburb, "address_ctr" => 0, "address_desc" => $cust_address_desc ), array( "address_id" => 0, "house_number" => $loc_address_number, "property_number" => $loc_address_fnumber, "street_name" => $loc_address_street, "street_type" => $loc_address_streettype, "locality" => $loc_address_suburb, "address_ctr" => 0, "address_desc" => $loc_address_desc ) ); $parameters->req_input->customer_name_det->customer_name_details = $customer_name_det; $parameters->req_input->address_det->address_details = $address_det; $parameters->req_input->ws_status = 0; $parameters->req_input->ws_message = ''; $wsdl = WEB_SERVICES_PATH.MERIT_REQUEST_FILE."?wsdl"; try { $client = new SoapClient ($wsdl, array ("classmap" => array ("ws_create_request" => "Request"))); $result = $client->ws_create_request($parameters)->ws_create_requestResult; } catch (Exception $e) { echo $e -> getMessage (); } Notice where I have the $customer_name_det and $address_det variables. They're the ones that are nested as you'll see in the web service sample. I've tried putting each into an array and then just setting customer_name_det->customer_name_details to that array variable (and address_det->address_details as well ), but when passed through that fails to work as well. How should I input data into these nested objects in a web service?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.