Link to home
Start Free TrialLog in
Avatar of lonnyo
lonnyo

asked on

Password protecting a web service

I have a web service that provides information on coupons that I would like to protect with a  password.  I have the web service working, but I can't figure out how to password protect it. I have the value of the password set just below the cfcomponent tag.

I also would like to have an optional argument where the MemberID can be passed to pull coupons for a specific business (member). I am thinking for this, I should be able to add the following to the query:

<cfif IsDefined("MemberID")>
            AND MemberID = <cfqueryparam value="#MemberID#" cfsqltype="cf_sql_integer">
            </cfif>

and then add the following argument:

<cfargument name="MemberID"
      type="string"
      required="no">


The call is working, but it does not matter if the password is correct or not. Here is the code I have so far (I left out the part about the second argument for now to focus on the password):
<cfcomponent>	
  <cfset DataSource = "burnsville_cvb">
  <cfset Password = "mypassword">
  <cffunction name="listCoupons"
    access="remote"
    returntype="string"
    output="no">

    <cfargument name="Password"
      type="string"
      required="yes">
      

    <cfset Var CouponList = "">
    <cfset Var getCoupons = "">
    <cfquery datasource="#DataSource#" name="getCoupons">
		SELECT CouponID, MemberID, VenueDefID, Offer, Description, Disclaimer, Code, Post, Expire
		FROM coupons
        WHERE ((NOW() BETWEEN Post AND Expire) OR (Post <= NOW() AND Expire IS NULL))
        
	</cfquery>

    <cfsavecontent variable="CouponList">
      <coupons>
        <cfoutput query="getCoupons">
          <coupon couponid="#CouponID#">
          	<memberid>#XMLFormat(MemberID)#</memberid>
            <venuedefid>#XMLFormat(VenueDefID)#</venuedefid>
            <offer>#XMLFormat(Offer)#</offer>
            <description>#XMLFormat(Description)#</description>
            <disclaimer>#XMLFormat(Disclaimer)#</disclaimer>
            <code>#XMLFormat(Code)#</code>
            <post>#XMLFormat(Post)#</post>
            <expire>#XMLFormat(Expire)#</expire>
          </coupon>
        </cfoutput>
      </coupons>
    </cfsavecontent>

    <cfreturn CouponList>
  </cffunction>
</cfcomponent>

Open in new window


Here is the code I am using to call the web service:
<cfinvoke
   method="listCoupons"
   returnvariable="rawXMLCouponList"
   webservice="http://www.burnsvillemn.com/cfcomponents/coupons8.cfc?wsdl">

   <cfinvokeargument name="Password" value="mypassword">
</cfinvoke>

<cfset thecoupons = XmlParse(rawXMLCouponList)>

<cfdump var="#thecoupons#">

Open in new window


Any help would be appreciated.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of SidFishes
SidFishes
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lonnyo
lonnyo

ASKER

thank you that worked