PHP_TRY_HARD Posted March 19, 2010 Share Posted March 19, 2010 I am making my own SOAP client that needs to call from a preexisting web service. I can access the WSDL that they supplied, so I need to build the SOAPclient backwards. I don't really know what I am doing so would appreciate any help. Thank you in advance. THE WSDL XML POST *****/PriceCalculationWS.asmx HTTP/1.1 Host: ***.***.com Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://localhost/DriveAwayPriceCalculation/PriceCalculation" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <AuthHeader xmlns="http://localhost/DriveAwayPriceCalculation/"> <UserName>string</UserName> <Password>string</Password> <errorMessage>string</errorMessage> </AuthHeader> </soap:Header> <soap:Body> <PriceCalculation xmlns="http://localhost/DriveAwayPriceCalculation/"> <requestObject> <UserName>string</UserName> <Password>string</Password> <CompanyCode>int</CompanyCode> <MLP>double</MLP> <OptionsPrice>double</OptionsPrice> <DealerDeliveryCharge>double</DealerDeliveryCharge> <DriveAwayCalculationFlag>N or Y</DriveAwayCalculationFlag> <HybridVehicle>N or Y</HybridVehicle> <PrivateOrBusinessUse>P or B</PrivateOrBusinessUse> <VehicleTareWeight>double</VehicleTareWeight> <EngineCapacity>int</EngineCapacity> <NumberOfCylinders>int</NumberOfCylinders> <Postcode>string</Postcode> <CombinedCyclefuelConsumption>double</CombinedCyclefuelConsumption> <InsurerCode>string</InsurerCode> <ElectricVehicle>N or Y</ElectricVehicle> <GVR>char</GVR> </requestObject> </PriceCalculation> </soap:Body> </soap:Envelope> Annd My PHP SOAPclient attempt <?php require_once('nusoap.php'); $client = new nusoap_client('https://****.asmx',true); $auth_array = array( 'user_auth' => array( 'UserName' => 'Username', 'password' => 'Password', 'errorMessage' => 'error processing data', ) ); //Here is where we actually send the data. We are calling the 'login' SOAP method $login_results = $client->call('login',$auth_array); // The following lines will use the set_entry SOAP call to add // a Lead from a mixture of POST variables and hard coded // values, then assign to the authenticated user... $set_entry_params = array( 'module_name' => 'PriceCalculation', 'name_value_list'=>array( array('name'=>'UserName', UserName '), array('name'=>'Password',' Password '), array('name'=>'CompanyCode', '00'), array('name'=>'MLP', 'double'), array('name'=>'OptionsPrice', 'double'), array('name'=>'DealerDeliveryCharge','double'), array('name'=>'DriveAwayCalculationFlag','Y'), array('name'=>'PrivateOrBusinessUse','P'), array('name'=>'VehicleTareWeight','2000'), array('name'=>'EngineCapacity','2600'), array('name'=>'NumberOfCylinders','4'), array('name'=>'Postcode','2600'), array('name'=>'Postcode','value'=>$_POST['Postcode']), array('name'=>'CombinedCyclefuelConsumption','double'), array('name'=>'InsurerCode','767'), array('name'=>'ElectricVehicle','N'))); $result = $soapclient->call('set_entry',$set_entry_params); echo "The Drive Away price for the car is $VehicleDriveAwayPrice"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/195772-soapclient/ Share on other sites More sharing options...
PHP_TRY_HARD Posted March 23, 2010 Author Share Posted March 23, 2010 I have the body working now but still struglling with the headers. Any advice?? $SOAPAction = 'http://localhost/test'; //Namespace of the WS. // $AuthHeader = array('TestUser' => $UserName, 'TestPassword' => $Password, '' => $errorMessage); $client = new nusoap_client("https://testWS.asmx?WSDL", true); $headers = new SoapHeader('http://localhost/test', 'AuthHeader', true); I am using nuSOAP Quote Link to comment https://forums.phpfreaks.com/topic/195772-soapclient/#findComment-1030372 Share on other sites More sharing options...
PHP_TRY_HARD Posted March 25, 2010 Author Share Posted March 25, 2010 I fixed it, I think it is cheating a little but it has given me the result I wanted. I just added the XML code to the headers. $client->setHeaders("<AuthHeader xmlns=\"http://localhost/test/\"><UserName>User123</UserName><Password>Password123</Password><errorMessage></errorMessage></AuthHeader>"); Quote Link to comment https://forums.phpfreaks.com/topic/195772-soapclient/#findComment-1031942 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.