PHP - Php & Soap Efficiency - Help With Small Code Please
Similar TutorialsHello,
I hope it's ok to ask this question here. I have a registration script, but I'm not sure how to handle it efficiently and I have some questions about it. This is used in the page 'signup.php'. The class is called 'User'. I haven't noticed any errors or bugs. It would be very useful for me to be aware of my mistakes. public function regUser($uname,$upass,$upassverify) { $new_password = password_hash($upass, PASSWORD_DEFAULT); if(!password_verify($upassverify, $new_password)) { // passwords are not the same (I thought it would be better to do this after hashing, but maybe it doesn't matter or it's worse. I'm not sure about it) $info = 'pass_err'; } $stmt1 = $this->db->prepare("SELECT * FROM users WHERE username=:uname"); $stmt1->execute(array(':uname'=>$uname)); if($stmt1->rowCount() > 0) { // this username has already been used $info = 'user_err'; } if (!$info) { $stmt2 = $this->db->prepare("INSERT INTO users(username,password) VALUES(:uname, :upass)"); $stmt2->bindparam(":uname", $uname); $stmt2->bindparam(":upass", $new_password); $stmt2->execute(); // succesfully made an account $info = "success"; } header("Location:/signup.php?status=".$info); exit(); }Am I using the prepared statements as how I should be using them? Is this a safe way of handling my data or do you see vulnerabilities? I'm using PRG to prevent resubmission but I want to show a 'everything is fine' or 'oh no, something went wrong' to the one who is signinup. If I now go to signup.php?status=success, i see 'eveything is fine', without actually signing up, is there a better way to do this or can I somehow prevent everyone being able to see this? As you might have noticed in my last post, my English is not very good, sorry about that. Thanks, Fabian Edited September 17, 2019 by FabelHello, This is supposed to be a sample soap request. I don't know how to actually send the request with php. Code: [Select] POST /sendSms.asmx HTTP/1.1 Host: host_site.com Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://some_uri.com/sendSms" <?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:Body> <sendSms xmlns="http://some_uri.com/"> <username>string</username> <password>string</password> <smsContent> <string>string</string> <string>string</string> </smsContent> <cell> <string>string</string> <string>string</string> </cell> <from>string</from> </sendSms> </soap:Body> </soap:Envelope> How am I supposed to so send this info? What is soapAction there? I tried: Code: [Select] $client = new SoapClient("host_site.com/sendSms.asmx"); and I'm getting: Quote Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'host_site.com/sendSms.asmx' : Premature end of data in tag html line 3 in ... I was wondering if someone can tell me what I have done wrong with this code: <?php foreach ($row['received'] as $data) { $data += $received; } echo $received; ?> It should be adding the number 2 three times, so it should be echoing 6 but its not. Problem 1 I have is that nothing is being added to the variable $received, and problem 2 is that I suspect $received will not become 6, but rather 222. Am I correct? Code: Code: [Select] <table border='0' style="height:100%;width:570px;border:solid 1px #BBB"> Error: Code: [Select] Parse error: parse error, expecting `','' or `';'' in C:\xampp\htdocs\sources\admin\manage-user.php on line 26 Sorry, im a noob when it comes to coding. please help! My Error Output is this: Warning: Cannot modify header information - headers already sent by (output started at city-search.php:1) in city-search.php on line 65 What I'm I missing in the code, I can't seem to get these. It works excellent in Localhost, but in production. Error above. Code: [Select] <?php // MG CREATED THIS SIMPLE REGISTRATION PHP FOR THAT GOES TO ONE SPECIFIC USER. // WILL TEST FORM REGSITRATION NG 07-2011 //If the form is submitted if(isset($_POST['submit'])) { //Check to make sure that the name field is not empty if(trim($_POST['name']) == '') { $hasError = true; } else { $name = trim($_POST['name']); } //Check to make sure that the subject field is not empty if(trim($_POST['subject']) == '') { $hasError = true; } else { $subject = trim($_POST['subject']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['email']) == '') { $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) { $hasError = true; } else { $email = trim($_POST['email']); } //Check to make sure comments were entered if(trim($_POST['message']) == '') { //$hasError = true; $comments == 'Have No Friends'; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['message'])); } else { $comments = trim($_POST['message']); } } //If there is no error, send the email if(!isset($hasError)) { //$emailTo = 'regina@shushmedeals.com'; //$emailTo = 'reginabyrd32@yahoo.com'; $emailTo = 'mp3@danjaproduction.com'; //$emailBcc = 'ganja99@netzero.net'; //$emailBcc = 'info@danjaproduction.com'; //$emailBcc = 'ganja99@netzero.net'; //Put your own email address here $body = "Location: $name \n\nEmail: $email \n\nShushMeDeals Sign-up Info:\n $comments"; // To send HTML mail, the Content-type header must be set $headers = 'From: ShushMeDeals.com City Location sign-up - '.$name.'' . "\r\n" . 'Reply-To: ' . $email . "\r\n" .'Bcc: print@extremeatlanta.com'; //$headers .= 'Cc: birthdayarchive@example.com' . "\r\n"; //$headers .= 'Bcc: info@danjaproduction.com' . "\r\n"; mail($emailTo, $subject, $body, $headers); $emailSent = true; if($emailSent = true) { setcookie("location", $name); //echo '<script type="text/javascript"> // window.location = "index.php?option=com_enmasse&controller=deal&task=today&locationName='.$name.'" // </script>'; } } } ?> I have a problem with the below code: Code: [Select] <?php $sql_ranks = ("SELECT vtp_members.id, vtp_members.name, vtp_members.teamleader, teams.team_name, count(vtp_tracking.id) surfs FROM vtp_members, vtp_tracking, teams WHERE vtp_members.team_id=".$_GET['t']." AND vtp_tracking.credit_members_id=vtp_members.id AND vtp_tracking.action_date > '$last_sunday' AND vtp_tracking.action_date < '$next_sunday' GROUP BY teams.team_name ORDER BY surfs DESC"); $rsranks = mysql_query($sql_ranks); echo "<br><table align='center' valign='top' border='0' width='300px'> <tr><td colspan='2' align='center'><font size='2px'><b>Team Rankings (Current Week)</b></font></td></tr> <tr><td><font size='2px'><b>Team</font></td><td align='right'><font size='2px'>Total Surfs</font></td></tr>"; while ($row = mysql_fetch_array($rsranks)) { echo "<tr><td><font size='2px'><b>".$row[team_name]."</font></td><td align='right'><font size='2px'>".$row[surfs]."</font></td></tr>";} echo "</table>"; ?> Problem is that the last output (".$row[surfs].") is the same for all teams. It seems it is not making a total of all id's and not per team_name. anyone can see what I am doing wrong. I need to sort by team_name and the surfs should display the total of the members with team_id is ".$_GET['t']." Just looking for an opinion on which one of these two pieces of code would process faster: <tr align="center" class="border"> <td class="border">'; if($copper=="yes"){ $content.= '<span class="strike">Copper</span>'; } else{ $content.= 'Copper'; } $content.=' </td> <td class="border"> '; if($copper=="yes"){ $content.= '<span class="strike">$10 - $35</span>'; } else{ $content.= ' $10 - $35'; } $content.=' </td> <td class="border">'; if($copper=="yes"){ $content.= '<span class="strike">800</span>'; } else{ $content.= ' 800'; } $content.=' </td> <td class="border">'; if($copper=="yes"){ $content.='Levels that are crossed out are full.'; } else{ $content.='Name in end Credits + Nickel Level'; } $content.=' </td> </tr> vs. if($copper=="yes"){ <tr align="center" class="border"> <td class="border"> <span class="strike">Copper</span> </td> <td class="border"> <span class="strike">$10 - $35</span> </td> <td class="border"> <span class="strike">800</span> </td> <td class="border"> Levels that are crossed out are full. </td> </tr> } else{ <tr align="center" class="border"> <td class="border"> Copper </td> <td class="border"> $10 - $35 </td> <td class="border"> 800 </td> <td class="border"> Name in end Credits + Nickel Level </td> </tr> } Okay, I have no idea how this works out but this is really getting on my nerves. Here is my logic for the following code. I manually register a user, It goes into the database and dispatches an email notification explaining that a user must activate their account and change their user name (OPTIONAL) and password. In the email, There is an automatically generated password with the username, And a link to activate the account. This leads to stage 1 of the activation process, In this stage the user is accepted, Registered as a verified user and then is sent to another page to change the details like login and password. As far as I know this page works except through trial and error I found that this little snippet of code is causing browsers to show an error 500 page, If I remove this the page works: <?php if($messages){ displayErrors($messages); } else { echo("<p align=\"center\" class=\"standard\">Your account has been activated.</p><p align=\"center\" class=\"standard\">You now need to change your password. If you like you can also change your username, Remember that you only have 3 days to do so and this change will be permanent.</p>"); } ?> and this is the displayErrors function: <?php function displayErrors($messages) { print("<p align=\"center\" class=\"standard\">"."<b>There were problems with the previous action:</b>\n<ul>\n"); foreach($messages as $msg){ print("<li>$msg</li>\n"); } print("</ul>\n"."</p>"); } ?> The displayErrors function is in a file called functions.php, Which is included in config.php, Which is included in every page including this one. The entire "Change password and login page thingie" is he <?php include("config.php"); global $link, $messages; require_once('recaptchalib.php'); if($_GET['error']){ $id=$_GET['id']; $messages[]="There is more than one or no accounts with the verification code you are using. <a href=\"mailto:rentals@nivso.co.uk?subject=Two or no accounts with activation ID of $id\">Click here to email us about this and have the problem sorted.</a>"; doIndex(); exit; } if(isset($_POST['submit'])){ if(!isset($_POST['activationid'])){ die("Doesn't exist -.- might as well quit this is *STUFF* -.-"); } $privatekey = "YOUR NOT HAVING THIS"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { $messages[]="The code you entered is incorrect. Please go back and try again!"; doIndex(); exit; // exit or the below lines will be processed. } else { //This is where the fun starts! $login=$_POST['login']; $passw=$_POST['password']; $passc=$_POST['passwordc']; $id2=$_POST['activationid']; $changinglogin=false; $get1=excDB("SELECT * FROM `users` WHERE `activeID`='$id2'"); if($get1[0]){ $get1=$get1[1]; } else { die($get1[2]); } $pro1=mysql_fetch_array($get1); if($pro1['login']!=$login){ $changinglogin=true; field_validator("Login", $login, "alphanumeric", 4, 15); } field_validator("Password", $passw, "string", 6, 20); if($passw!=$passc){ $messages[]="The passwords do not match, Please make sure that the passwords are the same!"; } if($messages){ doIndex(); exit; } $passcl=mysql_escape_string($passw); $passen=md5($passcl); if($changinglogin){ $wri1=excDB("UPDATE `users` SET `login`='$login', `password`='$passen', `passchange`='1', `loginchange`='1' WHERE `activeID`='$id2';"); if($wri1[0]){ $wri1=$wri1[1]; } else { die($wri1[2]); } header("Location: login.php?created"); } else { $wri1=excDB("UPDATE `users` SET `password`='$passen', `passchange`='1', `loginchange`='0' WHERE `activeID`='$id2';"); if($wri1[0]){ $wri1=$wri1[1]; } else { die($wri1[2]); } header("Location: login.php?created2"); } } } else { doIndex(); } function doIndex(){ ?> <!DOCTYPE html> <head> <title>Family Rental System! - Rent your DVDs here - Design by Alex, Coding by Gergy008</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link type="text/css" href="css/main.css" rel="stylesheet"> <style type="text/css"> <!-- body { background-color: #333333; } --> </style></head> <body style="text-align:center;"> <div class="first"> <div class="backgrounder1"></div> <div class="headerbar1"></div> <div class="headerbar2"></div> </div> <div align="center"> <table border="0" cellpadding="0" cellspacing="0" width="900"> <tr> <td><img src="images/spacer.gif" width="52" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="123" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="352" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="33" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="55" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="110" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="110" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="50" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="15" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="1" height="1" border="0" alt="" /></td> </tr> <tr> <td colspan="9" background="images/template.slice.1.png"> </td> <td><img src="images/spacer.gif" width="1" height="20" border="0" alt="" /></td> </tr> <tr> <td colspan="5" background="images/template.slice.2.png"> </td> <td colspan="2" rowspan="2" background="images/template.slice.3.png"><span class="login"><?php echo(loginHandler()); ?></span></td> <td colspan="2" rowspan="3" background="images/template.slice.4.png"> </td> <td><img src="images/spacer.gif" width="1" height="30" border="0" alt="" /></td> </tr> <tr> <td rowspan="8" background="images/template.slice.5.png"> </td> <td colspan="2" background="images/template.slice.6.png"><form> <div align="center"> <input name="textfield" type="text" id="textfield" size="40" style="height:16px;"> <input type="submit" name="button" id="button" value="Search" style="height:20px;"> </div> </form></td> <td colspan="2" rowspan="2" background="images/template.slice.7.png"> </td> <td><img src="images/spacer.gif" width="1" height="30" border="0" alt="" /></td> </tr> <tr> <td colspan="2" rowspan="3" background="images/template.slice.8.png"><p> </p> <p> </p></td> <td colspan="2" background="images/template.slice.9.png"> </td> <td><img src="images/spacer.gif" width="1" height="70" border="0" alt="" /></td> </tr> <tr> <td rowspan="2" background="images/template.slice.10.png"> </td> <td colspan="4" background="images/template.slice.11.png"> </td> <td rowspan="6" background="images/template.slice.12.png"> </td> <td><img src="images/spacer.gif" width="1" height="30" border="0" alt="" /></td> </tr> <tr> <td colspan="4" background="images/template.slice.13.png"></td> <td><img src="images/spacer.gif" width="1" height="8" border="0" alt="" /></td> </tr> <tr> <td rowspan="4" background="images/template.slice.14.png"> </td> <td colspan="4" background="images/template.slice.15.png"> </td> <td colspan="2" rowspan="4" background="images/template.slice.16.png"> </td> <td><img src="images/spacer.gif" width="1" height="35" border="0" alt="" /></td> </tr> <tr> <td colspan="4" background="images/template.slice.17.png"> </td> <td><img src="images/spacer.gif" width="1" height="37" border="0" alt="" /></td> </tr> <tr> <td colspan="4" align="center" valign="top" background="images/template.slice.18.png" style="vertical-align:top;"><p class="standard"> </p> <table width="80%" border="0"> <tr> <td colspan="2"> <?php if($messages){ //displayErrors($messages); } else { //echo("<p align=\"center\" class=\"standard\">Your account has been activated.</p><p align=\"center\" class=\"standard\">You now need to change your password. If you like you can also change your username, Remember that you only have 3 days to do so and this change will be permanent.</p>"); ?></td> </tr> <form name="ChangeDetails" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <input type="hidden" name="activationid" value="<?php if($_GET['id']){ $id=$_GET['id']; echo($id); } elseif($_POST['activationid']){ $id=$_POST['activationid']; echo($id); } else { die("No ID") } ?>" /> <tr> <td width="50%"><div align="right" class="standard">New Username: </div></td> <td width="50%"><input name="login" type="text" id="login" size="35" maxlength="30" /></td> </tr> <tr> <td><div align="right" class="standard">New Password:</div></td> <td><input name="password" type="password" id="password" size="35" maxlength="30" /></td> </tr> <tr> <td><div align="right" class="standard">Re-enter password:</div></td> <td><input name="passwordc" type="password" id="passwordc" size="35" maxlength="30" /></td> </tr> <tr> <td><div align="right" class="standard">Please enter the code: </div></td> <td> <?php require_once('recaptchalib.php'); $publickey = "6Le4fsESAAAAAKMOHb8aaiyDfGRJyr0y0EU7dXm-"; // you got this from the signup page echo recaptcha_get_html($publickey); ?> </td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" id="submit" value="Change your details" /></td> </tr> </form> </table> </td> <td><img src="images/spacer.gif" width="1" height="450" border="0" alt="" /></td> </tr> <tr> <td colspan="4" background="images/template.slice.19.png"> </td> <td><img src="images/spacer.gif" width="1" height="50" border="0" alt="" /></td> </tr> <tr> <td colspan="9" background="images/template.slice.20.png"> </td> <td><img src="images/spacer.gif" width="1" height="40" border="0" alt="" /></td> </tr> </table> </div> </body> </html> <?php } ?> Thanks to all you kind people that take your time to read and help me with this problem. I'm sorry if it is a really simple problem I missed out that makes me look like a right idiot and wasted your time, but that's me I'm always missing stuff out like that, I do proof read though just sometimes not good enough. Thanks in advance! Hello A question popped up in my head, while I was designing my database (this is both php and SQL thought). The scenario is that an item can have many categories. Yet the categories are finite (<100 let's say). I have no problem making a many to many link table. Yet I was wondering if the finite categories would necessitate this method. My thought is - make the categories table a default array and match it against a queried item (containing an array of category IDs) with an array_intersect. Is this efficient, silly, or a variable scenario? Thanks for any insight. Since I didn't want to type it out myself I wrote a small Date of Birth drop down menu generator. Now I'm wondering how I can make the code copy-able in a text area? The script should be inserting all the code ready and finished into a textarea so you can copy and go. How is it done? Here's the script: <?php echo "<center>"; ?> <form action='' method='POST'> <input type='submit' name='submit' /> </form> <?php $submit = $_POST['submit']; if ($submit) { echo "<form action='' method='POST'>"; echo "<select name='month'>"; for ($m = 01; $m <= 12; $m++) { echo " <option value='" . $m . "'>" . $m . "</option> "; } echo "</select>"; echo "<select name='day'>"; for ($d = 01; $d <= 31; $d++) { echo " <option value='" . $d . "'>" . $d . "</option> "; } echo "</select>"; echo "<select name='year'>"; for ($y = 1900; $y <= 2010; $y++) { echo " <option value='" . $y . "'>" . $y . "</option> "; } echo "</select>"; echo "</form>"; echo "</center>"; } ?> <html><head></head><body>stdClass Object ( [DealerSearchResult] => stdClass Object ( [any] => <xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet"><xs:element name="NewDataSet" msdata:isdataset="true" msdata:maindatatable="Dealer" msdata:usecurrentlocale="true"><xs:complextype><xs:choice minoccurs="0" maxoccurs="unbounded"><xs:element name="Dealer"><xs:complextype><xs:sequence><xs:element name="DealerID" type="xs:int" minoccurs="0"><xs:element name="TaxPayerNumber" type="xs:string" minoccurs="0"><xs:element name="LastName" type="xs:string" minoccurs="0"><xs:element name="Firstname" type="xs:string" minoccurs="0"><xs:element name="MiddleInitial" type="xs:string" minoccurs="0"><xs:element name="CompanyName" type="xs:string" minoccurs="0"><xs:element name="ShipAddress1" type="xs:string" minoccurs="0"><xs:element name="ShipAddress2" type="xs:string" minoccurs="0"><xs:element name="ShipCity" type="xs:string" minoccurs="0"><xs:element name="ShipState" type="xs:string" minoccurs="0"><xs:element name="ShipZip" type="xs:string" minoccurs="0"><xs:element name="ShipCountry" type="xs:string" minoccurs="0"><xs:element name="MailAddress1" type="xs:string" minoccurs="0"><xs:element name="MailAddress2" type="xs:string" minoccurs="0"><xs:element name="MailCity" type="xs:string" minoccurs="0"><xs:element name="MailState" type="xs:string" minoccurs="0"><xs:element name="MailZip" type="xs:string" minoccurs="0"><xs:element name="MailCountry" type="xs:string" minoccurs="0"><xs:element name="WorkPhone" type="xs:string" minoccurs="0"><xs:element name="HomePhone" type="xs:string" minoccurs="0"><xs:element name="FaxPhone" type="xs:string" minoccurs="0"><xs:element name="CellPhone" type="xs:string" minoccurs="0"><xs:element name="EnrollDate" type="xs:dateTime" minoccurs="0"><xs:element name="EmailPrimary" type="xs:string" minoccurs="0"><xs:element name="EmailSecondary" type="xs:string" minoccurs="0"><xs:element name="BirthDate" type="xs:dateTime" minoccurs="0"><xs:element name="Password" type="xs:string" minoccurs="0"><xs:element name="Account" type="xs:string" minoccurs="0"><xs:element name="SubAccount" type="xs:string" minoccurs="0"><xs:element name="Active" type="xs:short" minoccurs="0"><xs:element name="Deleted" type="xs:short" minoccurs="0"><xs:element name="DeleteDate" type="xs:dateTime" minoccurs="0"><xs:element name="DeleteBy" type="xs:string" minoccurs="0"><xs:element name="DealerURL" type="xs:string" minoccurs="0"><xs:element name="IsSentinal" type="xs:short" minoccurs="0"><xs:element name="TaxExempt" type="xs:short" minoccurs="0"><xs:element name="WebPhoto" type="xs:base64Binary" minoccurs="0"><xs:element name="WebGreeting" type="xs:string" minoccurs="0"><xs:element name="WebCatalogueID" type="xs:int" minoccurs="0"><xs:element name="WebProductID" type="xs:int" minoccurs="0"><xs:element name="NPO" type="xs:short" minoccurs="0"><xs:element name="IsCustomer" type="xs:short" minoccurs="0"><xs:element name="SponsoringDealerID" type="xs:int" minoccurs="0"><xs:element name="CurrencyTypeID" type="xs:int" minoccurs="0"><xs:element name="OldID" type="xs:string" minoccurs="0"><xs:element name="APPlacementDealerID" type="xs:int" minoccurs="0"><xs:element name="APDealershipNumber" type="xs:int" minoccurs="0"><xs:element name="APLineage" type="xs:string" minoccurs="0"><xs:element name="EmailOptOutUpline" type="xs:short" minoccurs="0"><xs:element name="EmailOptOutGlobal" type="xs:short" minoccurs="0"><xs:element name="EMailFormatTextOnly" type="xs:short" minoccurs="0"><xs:element name="DealerStatusCodeID" type="xs:int" minoccurs="0"><xs:element name="DateEmailPrimaryLastValidated" type="xs:dateTime" minoccurs="0"><xs:element name="EmailPrimaryValidated" type="xs:short" minoccurs="0"><xs:element name="EmailPrimaryValidationResult" type="xs:string" minoccurs="0"><xs:element name="DEFSponsorDealerID" type="xs:int" minoccurs="0"><xs:element name="DEFSponsorDealershipNumber" type="xs:int" minoccurs="0"><xs:element name="CustomerTypeID" type="xs:int" minoccurs="0"><xs:element name="DateExported" type="xs:dateTime" minoccurs="0"><xs:element name="AllowWebAccess" type="xs:short" minoccurs="0"><xs:element name="UseEWalletOnly" type="xs:int" minoccurs="0"><xs:element name="AffiliateSponsoringDealerID" type="xs:int" minoccurs="0"><xs:element name="SMSTextOptOut" type="xs:short" minoccurs="0"><xs:element name="SMSTextOnEnroll" type="xs:short" minoccurs="0"><xs:element name="SMSTextOnOrder" type="xs:short" minoccurs="0"><xs:element name="SMSTextInfoAlerts" type="xs:short" minoccurs="0"><xs:element name="CustomerStatusID" type="xs:int" minoccurs="0"><xs:element name="PayCurrencyTypeID" type="xs:int" minoccurs="0"><xs:element name="FullName" type="xs:string" minoccurs="0"></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:element></xs:sequence></xs:complextype></xs:element></xs:choice></xs:complextype></xs:element></xs:schema><diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"><documentelement xmlns=""><dealer diffgr:id="Dealer1" msdata:roworder="0"><dealerid>813242</dealerid><taxpayernumber>1</taxpayernumber><lastname>name</lastname><firstname>test</firstname><middleinitial><companyname>test company</companyname><shipaddress1>test address1 </shipaddress1><shipaddress2>test address 2</shipaddress2><shipcity>test city</shipcity><shipstate>N/A</shipstate><shipzip>tf1 7yl</shipzip><shipcountry>UK</shipcountry><mailaddress1>test address1 </mailaddress1><mailaddress2>test address 2</mailaddress2><mailcity>test city</mailcity><mailstate>N/A</mailstate><mailzip>tf1 7yl</mailzip><mailcountry>UK</mailcountry><workphone>01952 000 000</workphone><homephone><faxphone><cellphone><enrolldate>2014-06-03T00:00:00-05:00</enrolldate><emailprimary>test@test.com</emailprimary><emailsecondary><password>password</password><account>1</account><subaccount>0</subaccount><active>-1</active><deleted>0</deleted><dealerurl>testname</dealerurl><issentinal>0</issentinal><taxexempt>0</taxexempt><webcatalogueid>-1</webcatalogueid><webproductid>-1</webproductid><npo>0</npo><iscustomer>0</iscustomer><sponsoringdealerid>-1</sponsoringdealerid><oldid><emailoptoutupline>0</emailoptoutupline><emailoptoutglobal>0</emailoptoutglobal><emailformattextonly>0</emailformattextonly><emailprimaryvalidated>0</emailprimaryvalidated><customertypeid>0</customertypeid><allowwebaccess>-1</allowwebaccess><useewalletonly>0</useewalletonly><affiliatesponsoringdealerid>0</affiliatesponsoringdealerid><smstextoptout>-1</smstextoptout><smstextonenroll>0</smstextonenroll><smstextonorder>0</smstextonorder><smstextinfoalerts>0</smstextinfoalerts><customerstatusid>-1</customerstatusid><paycurrencytypeid>-1</paycurrencytypeid><fullname>test company</fullname></oldid></emailsecondary></cellphone></faxphone></homephone></middleinitial></dealer></documentelement></diffgr:diffgram> ) ) </body></html>this is the soap response i get from $client = new SoapClient("http://#########/WebServices/#####DealerWS.asmx?wsdl"); $result = $client->DealerSearch($params); print_r($result);bascly i want to take from this the info inside and use it as a object so i end up with $obj->LastName etc etc the diffgramm xml is the stuff i want, i can do it but manullly cuting out shcema xml $test = simplexml_load_string($result); $object = $test->DocumentElement->Dealer; echo $object->LastName; echo "<br>"; echo $object->CompanyName;but thats only when i use diffgram xml and as you can see the soap respone dose not work and throws extra content error if i try get it right so im doing it totally wrong can some one help me get it working with the response i supplyed and allow me use valuse like so i want above Hi guys, I have been tasked with a SOAP project at work. Basically we have a database on our own internal server that holds information on our customers. This database is managed by an external company and we are able to use predefined SOAP calls that will do certain things for us. We then have a website that the general public access to update their information. I am having trouble understanding how to connect the 2 systems. The website is built in PHP. I am really looking for a proper beginners guide on how to integrate the 2. Can anyone point me in the right direction? Thanks! Hi guys! I started working on a project involving connecting to a soap server (windows). Eight hours later i am nowhere. The documentation is horrible and searching for error messages is a task that never ends. So now i am back here to ask all you guys :-) First of all, i want to connect to a external server which ends in: Code: [Select] GatewayWebService.asmx?WSDL So i got the variable: Code: [Select] $client = new SoapClient("http://XXXXXXXX/GatewayWebService.asmx?WSDL", array('login'=> "XXXXX",'password'=> 'XXXXXX')); And i want to do a call like: Code: [Select] print($client->RetrieveArticles("Article")); So now i get an error: Code: [Select] php webservice-import.php PHP Catchable fatal error: Object of class stdClass could not be converted to string in /var/www/vhosts/test.shoerama.nl/httpdocs/maintenance/webservice-import.php on line 11 But i dont think that all above is very correct. So i want to ask you guys for some help. How can i get a call with, lets say, the first 10 records from the soap server? How do i do soap call? I recieved the following "code" from the guys that host the soap server: Code: [Select] sXml: <Parameters><timestamp>1</timestamp><branch>98</branch><pos>1</pos><languagecode></languagecode><maxitems>100</maxitems></Parameters> What do i do with this? Thanks in advance guys! Ok, so I need to send a SOAP message to my server, but I have never done this before. The complete SOAP message should be as follows: Code: [Select] <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http:// www.w3.org/2001/XMLSchema-instance"> <soapenv:Body><request><username>testuser</username> </request></soapenv:Body></soapenv:Envelope>I have been trying to get this to work for a while now and can't do it, so I need your help. Here is what I have right now: Code: [Select] $params = array('username'=>$username); $params2 = array('request'=>$params); $response = $client->invokeService($params2); var_dump($response); Please, any help is appreciated. I really don't understand this at all. I need help ASAP. I would like to connect to web service (I have url to wsdl), which is protected with SSL (I have certificate and password). I would like to do that in PHP - the only solution I know is using Soap, but there is no working reference on Google that does that. I only found erros (could not resolve host, could not parse wsdl and forbiden) but no solutions. Is there any posible way to do this?
One of many attempts is like this:
<?php $wsdl = "https://url-to/test.wsdl"; $local_cert = 'cert.pem'; $passphrase = 'key'; $soapClient = new SoapClient($wsdl, array('local_cert'=> $local_cert,'passphrase'=>$passphrase)); $theResponse = $soapClient->getCertificateInfo('','',''); ?> I am completely and utterly stuck on this. I have tried about 20 different examples but nothing works. I simply want to send an XML message to a web service and receive its response. (1) The url is europaytest.smart2pay.com/MerchantService.asmx. But, does it need ?wsdl on the end?? It could be europaytest.smart2pay.com/MerchantService.asmx?wsdl ?? (2) I need to send XML to the above url using 'SubmitRequest' as the 'action' value. I would have thought this would do it: Code: [Select] $client = new SoapClient("https://europaytest.smart2pay.com/MerchantService.asmx?wsdl"); $response = $client->__doRequest($xml, "https://europaytest.smart2pay.com/MerchantService.asmx", "SubmitRequest", 1.1); But it returns with this XML response message: Code: [Select] <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: SubmitRequest. at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message) at System.Web.Services.Protocols.SoapServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response) at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope> Helo, I need some help with downloading xml from remote server using SOAP in PHP this is sample SOAP code that i have from server: http://shop.megatrend.com/ClientWebServices/ClientWS.asmx Code: [Select] POST /ClientWebServices/ClientWS.asmx HTTP/1.1 Host: shop.megatrend.com Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://shop.megatrend.com/ClientWebServices/GetProducts" <?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:Body> <GetProducts xmlns="http://shop.megatrend.com/ClientWebServices/"> <username>string</username> <password>string</password> <OIB>string</OIB> </GetProducts> </soap:Body> </soap:Envelope> Code: [Select] HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?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:Body> <GetProductsResponse xmlns="http://shop.megatrend.com/ClientWebServices/"> <GetProductsResult> <WsProduct> <PN>string</PN> <Code>string</Code> <Name>string</Name> <Description>string</Description> <Manufacturer>string</Manufacturer> <Weight>decimal</Weight> <Available>boolean</Available> <Stock>int</Stock> <Warranty>string</Warranty> <Price>decimal</Price> <Images> <WsImage xsi:nil="true" /> <WsImage xsi:nil="true" /> </Images> <Descriptions> <WsDescriptionData xsi:nil="true" /> <WsDescriptionData xsi:nil="true" /> </Descriptions> </WsProduct> <WsProduct> <PN>string</PN> <Code>string</Code> <Name>string</Name> <Description>string</Description> <Manufacturer>string</Manufacturer> <Weight>decimal</Weight> <Available>boolean</Available> <Stock>int</Stock> <Warranty>string</Warranty> <Price>decimal</Price> <Images> <WsImage xsi:nil="true" /> <WsImage xsi:nil="true" /> </Images> <Descriptions> <WsDescriptionData xsi:nil="true" /> <WsDescriptionData xsi:nil="true" /> </Descriptions> </WsProduct> </GetProductsResult> </GetProductsResponse> </soap:Body> </soap:Envelope> this is piece of PHP code that i have that shud handle request: Code: [Select] function megatrend_download() { $local = dirname(__FILE__); $path = $local."/xml/megatrend.xml"; $path1 = $local."/xml/megatrend1.xml"; $request = array('username'=>'xxx','password'=>'xxx','oib'=>'xxx'); postPage($request,'http://shop.megatrend.com/ClientWebServices/GetProducts'); $curl2 = curl_init(); curl_setopt($curl2, CURLOPT_URL, 'http://shop.megatrend.com/ClientWebServices/ClientWS.asmx'); curl_setopt($curl2, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl2, CURLOPT_HEADER, false); curl_setopt($curl2, CURLOPT_RETURNTRANSFER, true); ...rest of functions... I am clearly missing something but i just cant get it! Help! OK guys, I'm working on a project that involves a SOAP api. I only have reference to the method list here - http://www.ilinc.com/pdf/documentation/ilinc-web-services.pdf . basically, I got it so that I assume it's connecting fine but no matter what I do I can't get a response. I'm assuming I'm having an Issue traversing the response XML but I don't even know how to test that. here's my code... $wsdl_url = 'http://webservice.ilinc.com/perl/ilinc/api/webservice/ilinc-api.pl?WSDL'; $client = new SOAPClient($wsdl_url); $options = array('APIVersion'=>'10.0','ClientID'=>'132449','AuthorizedUserName'=>'lwilliams@biosoteria.com','AuthorizedPassword'=>'*******'); $var = array('UserID'=>'lwilliams@biosoteria.com'); $testUser = $client->GetUserID($options,array('parameters'=>$var)); print $testUser; print $testUser->return->ErrorStr; print $testUser->return->ErrorID; Now in the above code, if I do print $testUser i get this response "Catchable fatal error: Object of class stdClass could not be converted to string in /home/content/12/5907812/html/SOAP_test2.php on line 7". the other two prints return nothing. here's a snippet of the example resonse for the GetUserID method <?xml version="1.0" ?> <iLinc:Response version="10.0" xmlns:iLinc="http://www.ilinc.com"> <iLinc:GetUserIDResponse Reference="reference"> <ErrorID>error-id</ErrorID> <ErrorStr>error-str</ErrorStr> <UserID>user-id</UserID> <EncryptedUserID>encrypted-user-id</EncryptedUserID> </iLinc:GetUserIDResponse> </iLinc:Response> Can anyone tell me what I'm doing wrong? I am trying to connect to ASC web service to do queries, however nothing seems to work. This is was i started with just to test and I am getting nothing also attached are the instructions I was provided: <?php $asc = new SoapClient('https://www.asc.gov/wsvc/ASCQuerySvc.asmx'); return $asc->GetQueryableFields(); ?> Any help would be appreciated. HI everyone, I am trying to write a simple php page using an sdk. The SDK api contains all wsdl files which do all the work. There's a soap.php which has all the functions and stores the output in $response. My php page includes soap.php and a function. The function is handled by soap.php and it will get the date from the appropriate wdsl file and store it in $response. It is stored in xml format using utf-16. If I run my php page frmo console, I get the output fine. If I run it from a browser, the page is empty but if I "view source", the date is there. What do I need to do in my php page to get $response actually displayed in a browser. Thanks Gino |