Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FoxPro: soap header autentication

Status
Not open for further replies.

zeteixeira

Programmer
Jun 3, 2011
3
PT
Hello,
I am trying to use a webservice using SOAP header with the authentication.
The code I'm using is the following:

LOCAL o as MSSOAP.SoapClient30
o = CREATEOBJECT("MSSOAP.SoapClient30")
loException = null
llError=.f.

lcUrl = "
TRY
o.MSSoapInit(lcUrl)
o.ConnectorProperty("AuthUser") = 'aaa'
o.ConnectorProperty("AuthPassword") = "XXXXXXXX"
o.ConnectorProperty("ConnectTimeout")=5000
o.ConnectorProperty("Timeout")=10000

o.teste('aaaa','bbbb')

CATCH TO loException
llError = .t.
ENDTRY

IF llError
MESSAGEBOX("Unable to load WSDL file from " + lcUrl)
return
ENDIF

The sample XML I have is the following:

<soapenv:Envelope xmlns:con="xmlns:soapenv=" <soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1"
xmlns:wsse=" <wsse:UsernameToken wsu:Id="UsernameToken-6"
xmlns:wsu=" <wsse:Username>NAME</wsse:Username>
<wsse:password
Type=" <wsse:Nonce
EncodingType="<wsu:Created>2011-02-03T15:46:23.035Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<con:Consulta_Input>
<con:Numero>0000000000</con:Numero>
<con:Codigo>1234567890ABC</con:Codigo>
</con:Consulta_Input>
</soapenv:Body>
</soapenv:Envelope>


Unfortunately I am not able to pass the authentication.
Someone can take a hint?


Thanks in Advanced.
Thanks,
 
When I attempt to register that web service using the Web Service Registration applet (from either the Toolbox or the Task Pane Manager), I get an error. So I think the problem may be with the web service, not with your code.

Tamar
 
hi again,

The address of the webservice is just an example.
The question is put in authentication header in the XML, as defined in the example.

Thank you very much any help.

 
Hello,

Unfortunately still can not overcome this problem,
I do not control the service is invoked, so I can not make changes on the server side.
I tried to create xml by hand, here's an example I have implemented, however the response continues to return error....

*************************
Create Cursor CurXML(Resposta M)
CREATE CURSOR CurTeste(Envio M)

TEXT TO strXML TEXTMERGE NOSHOW
<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope xmlns:con=" xmlns:soapenv="<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="<wsse:UsernameToken wsu:Id="UsernameToken-6" xmlns:wsu="<wsse:Username>USERNAME</wsse:Username>
<wsse:password Type="<wsse:Nonce EncodingType="<wsu:Created>2010-01-03T15:46:23.035Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<con:METODO_Input>
<con:NUMBER>0000</con:NUMBER>
<con:VAR>PASS</con:VAR>
</con:METODO_Input>
</soapenv:Body></soapenv:Envelope>
ENDTEXT


SELECT CurTeste
APPEND BLANK
Replace CurTeste.envio WITH strXML
SELECT Curteste
brow


** Carrega Estrutura XML
vDoc = CreateObject('Msxml2.DOMDocument')
_Sync = vDoc.async = .F.
_Load = vDoc.loadXML(CurTeste.envio)

** Envia Estructura XML
TRANS_CERTIFICATE_NAME="0000001266"
vEnv = CreateObject('Msxml2.XMLHTTP')
_Open = vEnv.open('POST','_SetR = vEnv.setRequestHeader("Content-Type", "application/x-_Send = vEnv.send(vDoc)

** Resposta
Select CurXML
Append Blank
Replace Next 1 Resposta With vEnv.responseText

Select CurXML
brow
*************************

The response I get is:

**************
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="<env:Header/>
<env:Body>
<env:Fault xmlns="<faultcode xmlns="">:AAA</faultcode>
<faultstring xmlns="">Cannot figure out operation name. Bad SOAPAction or wsa:Action.</faultstring>
<faultactor xmlns=""/></env:Fault>
</env:Body>
</env:Envelope>
**************************

Thanks for any help.
 
Common, read from "The SOAP client", to see what you need to do on the client side.

You need the ClientHeaderHandler class of course.
For it's usage you set the HeaderHandler Property of your "MSSOAP.SoapClient30" instance (which you call "o") to an instance of the ClientHeaderHandler (that is o.HeaderHandler = Createobject("ClientHeaderHandler"), and it will handle the headers as defined in the code autoamtically while you simply use any of the methods the Webservice offers.

The hard part to see what kind of things you need in the header. As I don't know the service you're I don't know the specifics.

It's hard to help you without connecting to the same webservice.

Bye, Olaf.
 
Olá
Sempre conseguiste alguma coisa com a validacao na acss, também estou tentando e não consegui nada, alguma forma de nos podermos contactar.
João
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top