frutuopa Posted March 28, 2022 at 05:17 PM Report Share #625661 Posted March 28, 2022 at 05:17 PM Boa Tarde Estou a tentar consumir este webservice da Associacao Portuguesa do Ambiente. Ja tenho usado outros Webservices, mas sem autenticação. https://qualsiliamb.apambiente.pt/services/egar/GuiaAcompanhamentoWs/v2?wsdl= consigo faze-lo a partir de um cliente Soap. mas tenho de adicionar no xml, o user e a password, bem como um token que me foi fornecido os passos que dei foi 1 - Adicionei um service reference 2 - No codigo Dim ws As New WSEGAR.GuiaAcompanhamentoWsClient ws.ClientCredentials.UserName.UserName = "myusername" ws.ClientCredentials.UserName.Password = "mypwd" Dim wsArgOutput As New WSEGAR.consultarGuiaDetalheOutput Dim wsArgInput As New WSEGAR.consultarGuiaInput Dim identGuia As New WSEGAR.identificadorGuia wsArgInput.tokenCertificacao = "88PfKOQmA7CdjBXj" identGuia.numeroGuia = "PT20220324621342" identGuia.codigoVerificacao = "62ca77d59d140430" wsArgInput.idGuia = identGuia wsArgOutput = ws.consultarGuiaDetalhe(wsArgInput) da-me sempre um erro "FAult Ocurring While processing" parece-me que o problema é na identificacao : ws.ClientCredentials.UserName.UserName = "myusername" ws.ClientCredentials.UserName.Password = "mypwd" Ha outra forma de o fazer? Muito Obrigado Paulo Frutuoso Link to comment Share on other sites More sharing options...
frutuopa Posted April 4, 2022 at 08:59 PM Author Report Share #625708 Posted April 4, 2022 at 08:59 PM Boa Noite Mais alguma informação, para ver se me conseguem ajudar. 1 - No app.config fiz um header para o endpoint. <endpoint address="http://qualsiliamb.apambiente.pt/services/egar/GuiaAcompanhamentoWs/v2" binding="basicHttpBinding" bindingConfiguration="GuiaAcompanhamentoImplServiceSoapBinding" contract="WSEGAR.GuiaAcompanhamentoWs" name="GuiaAcompanhamentoWsPort"> <headers> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsse:UsernameToken wsu:Id="UsernameToken-6CB8DA3F8A8B95CABD16486289621351"> <wsse:Username>MYUSERNAME</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">MYPWD</wsse:Password> <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">sbc6emxNkMrdjI01XC/vAA==</wsse:Nonce> <wsu:Created>2022-03-30T08:29:22.133Z</wsu:Created> </wsse:UsernameToken> </wsse:Security> </headers> </endpoint> 2 - Instalei o Fiddler e consigo interceptar o XML, que é enviado pelo codigo anterior .... Se o colocar num cliente Soap (Soap UI), consigo obter a resposta perfeitamente 3 - Gerei um certificado SSL Obrigado Paulo Frutuoso Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now