E-Mail validation

Cringer

ProgressTalk.com Moderator
Staff member
What are the rules of the validation? Shouldn't be a hard job to do yourself if you look at the rules.

Generally a terse demand like this is much less likely to get results than a politely worded request with a 'please'.
 

Cringer

ProgressTalk.com Moderator
Staff member
You need to define exactly what you want. Then you can work out how to solve the problem. There seem to be some rather huge assumptions being made. First, that my definitions of terms are the same as yours. Second, that you have a right to receive the code you want. Neither of these are true. I would suggest you give the question some thought yourself and see how far you get. Then I would suggest you ask the question in a friendly way, showing what you've managed to do so far and asking if someone might be able to spare some time to help.

Never assume. It makes an *** out of you and me.
 

tamhas

ProgressTalk.com Sponsor
If what you are asking for is code to validate that a string is validly formatted as an e-mail address, then the problem is much more difficult than you think. While the most common addresses are name@domain.tld, there are many interesting and valid things that can appear in the name space. And, within the domain, only the name is necessary and it is still valid. So, you need to decide what you want to accept. If you will always want the part after the @, then use R-INDEX to find a trailing @ (error if there isn't one), SUBSTRING to pick off the piece after it, R-INDEX again to pick off the TLD, and validate the TLD against a list (which you will continue to have to update.

Or, just send a test e-mail and see if you get an error.
 

rstanciu

Member
If your Progress version is 10.x try this ...

/* client_ValidateEmail.p */

DEFINE VARIABLE hWebService AS HANDLE NO-UNDO.
DEFINE VARIABLE hXWebEmailValidationInterface AS HANDLE NO-UNDO.

CREATE SERVER hWebService.
hWebService:CONNECT("-WSDL 'http://ws.xwebservices.com/XWebEmailValidation/V2/XWebEmailValidation.wsdl'").

RUN XWebEmailValidationInterface SET hXWebEmailValidationInterface ON hWebService.

DEFINE VARIABLE Email AS CHARACTER NO-UNDO.
DEFINE VARIABLE Status1 AS CHARACTER NO-UNDO.

Email = "rstanciu@operamail.com".

RUN ValidateEmail IN hXWebEmailValidationInterface
(INPUT Email, OUTPUT Status1).

MESSAGE Status1 VIEW-AS ALERT-BOX.

DELETE PROCEDURE hXWebEmailValidationInterface.
hWebService:DISCONNECT().
DELETE OBJECT hWebService.
 

Cringer

ProgressTalk.com Moderator
Staff member
You're a lot more gracious than me it seems! :) Given that a good test and I like it a lot. Works nicely. Hopefully OP will be happy.

Popping that code into code tags to fix the smiley... ;)

Code:
/* client_ValidateEmail.p */

DEFINE VARIABLE hWebService AS HANDLE NO-UNDO.
DEFINE VARIABLE hXWebEmailValidationInterface AS HANDLE NO-UNDO.

CREATE SERVER hWebService.
hWebService:CONNECT("-WSDL 'http://ws.xwebservices.com/XWebEmailValidation/V2/XWebEmailValidation.wsdl'").

RUN XWebEmailValidationInterface SET hXWebEmailValidationInterface ON hWebService.

DEFINE VARIABLE Email AS CHARACTER NO-UNDO.
DEFINE VARIABLE Status1 AS CHARACTER NO-UNDO.

Email = "rstanciu@operamail.com".

RUN ValidateEmail IN hXWebEmailValidationInterface
  (INPUT Email, OUTPUT Status1).

MESSAGE Status1 VIEW-AS ALERT-BOX.

DELETE PROCEDURE hXWebEmailValidationInterface.
hWebService:DISCONNECT().
DELETE OBJECT hWebService.
 

rstanciu

Member
I have another cool ... sample to check the weather ...
-2 C° at Aeroport Charles De Gaulle ( France )

Code:
/*******************************************************************/
/* client_WeatherG.p */
/*******************************************************************/
DEFINE VARIABLE hWebService AS HANDLE    NO-UNDO.
DEFINE VARIABLE hPortType   AS HANDLE    NO-UNDO.
DEFINE VARIABLE cResponse   AS CHARACTER NO-UNDO.
DEFINE VARIABLE li          AS INTEGER   NO-UNDO.
DEFINE VARIABLE retValue    AS CHARACTER INITIAL "OK" NO-UNDO.
DEFINE VARIABLE err         AS LOGICAL   NO-UNDO.
DEFINE VARIABLE result      AS CHARACTER NO-UNDO.
DEFINE STREAM ls.
/*******************************************************************/
CREATE SERVER hWebService.
ETIME(true).
li = MTIME.

hWebService:CONNECT("-WSDL 'http://www.webservicex.net/globalweather.asmx?WSDL'
  -Service GlobalWeather
  -Port GlobalWeatherSoap").


IF NOT hWebService:CONNECTED() THEN DO:
    MESSAGE "SERVER NOT CONNECTED" VIEW-AS ALERT-BOX.
    retValue = "ERROR".
END.


RUN GlobalWeatherSoap SET hPortType ON SERVER hWebService NO-ERROR.

IF ERROR-STATUS:ERROR THEN DO:
    MESSAGE "Failed to create hPortType" VIEW-AS ALERT-BOX.
    retValue = "ERROR".
END.

DEFINE VARIABLE CountryName      AS CHARACTER NO-UNDO.
DEFINE VARIABLE GetWeatherResult AS CHARACTER NO-UNDO.
DEFINE VARIABLE CityName         AS CHARACTER NO-UNDO.
CountryName = "FRANCE".
CityName = "Paris-Aeroport Charles De Gaulle".

RUN GetWeather IN hPortType(
  INPUT CityName,
  INPUT CountryName,
  OUTPUT GetWeatherResult).

RUN ErrorInfo (OUTPUT err).
IF NOT err THEN DO:
    MESSAGE GetWeatherResult "~n"
     STRING(MTIME - li) " milisecondes."
     VIEW-AS ALERT-BOX.
END.
ELSE DO:
    retValue = "ERROR".
END.


DELETE PROCEDURE hPortType.
hWebService:DISCONNECT().
DELETE OBJECT hWebService.

RETURN retValue.
/*******************************************************************/
PROCEDURE ErrorInfo: /*1*/
  DEFINE OUTPUT PARAMETER errorfound AS LOGICAL INITIAL FALSE.
  DEFINE VARIABLE i                  AS INTEGER NO-UNDO.
  DEFINE VARIABLE hSOAPFault         AS HANDLE NO-UNDO.
  DEFINE VARIABLE hSOAPFaultDetail   AS HANDLE NO-UNDO.
  DEFINE VARIABLE HeaderXML AS LONGCHAR VIEW-AS EDITOR SIZE 70 BY 15 LARGE.
  IF ERROR-STATUS:NUM-MESSAGES > 0 THEN DO:
     errorfound = TRUE.
     DO i = 1 TO ERROR-STATUS:NUM-MESSAGES:
        MESSAGE ERROR-STATUS:GET-MESSAGE(i) VIEW-AS ALERT-BOX.
     END.
/*2*/
     IF VALID-HANDLE(ERROR-STATUS:ERROR-OBJECT-DETAIL) THEN DO:
       hSOAPFault = ERROR-STATUS:ERROR-OBJECT-DETAIL.
       MESSAGE
       "Fault Code: "   hSOAPFault:SOAP-FAULT-CODE        SKIP
       "Fault String: " hSOAPFault:SOAP-FAULT-STRING      SKIP
       "Fault Actor: "  hSOAPFault:SOAP-FAULT-ACTOR       SKIP
       "Error Type: "   hSOAPFault:TYPE  VIEW-AS ALERT-BOX.
/*3*/
       IF VALID-HANDLE(hSOAPFault:SOAP-FAULT-DETAIL) THEN  DO:
            hSOAPFaultDetail = hSOAPFault:SOAP-FAULT-DETAIL.
            MESSAGE  "Error Type: " hSOAPFaultDetail:TYPE
                     VIEW-AS ALERT-BOX.
            HeaderXML = hSOAPFaultDetail:GET-SERIALIZED().
            DISPLAY HeaderXML LABEL "Serialized SOAP fault detail"
                    WITH FRAME a.
        END.
     END.
  END.
END PROCEDURE.
/*******************************************************************/
 
Hi,


Windows 7 and Progress 10.2b

I have been asked to provide validation on email addresses so have been trying to run the /* client_ValidateEmail.p */ program as above but am getting the following error. Any help gratefully received.

Web Service operation ValidateEmail generated a SOAP Fault. Soap
faultstring is: Microsoft.Web.Servicess3.Security.SecurityFault: Security
requirements are not satisfied because the security header is not
present in the incoming message.(11506)


Sorry but I do not know anything about SOAP/wsdl

Regards
Mike
 
Top