How to authenticate when consuming a SOAP service?

Asked

Viewed 229 times

0

I need to make calls to a Web Service to send some information.

I did it this way:

  • I started a Winform application
  • I imported the address that became . WSDL in the project
  • I imported the classes and used them correctly by placing the values for their properties

Below I demonstrate simply the classes and how I did:

PortTypeClient Servico = new PortTypeClient();
DownpaymentRequest Numerario = new DownpaymentRequest();
header Header = new header();

itemData[] Array_Item = new itemData[1];

itemData Item = new itemData();

DownPaymentResponse Response = new DownPaymentResponse();

Header.tx_company_code = "1021";
Header.tx_document_type = "KA";     
Item.tx_account = "10184958";
Item.tx_gl_indicator = "A";     
Array_Item[0] = Item;
Numerario.header = Header;
Numerario.item = Array_Item;

try
{
  // onde de fato envio a requisição e pego a resposta no Response :)
  Response = Servico.PostInboundDownpayment(Numerario);
}
catch  (Exception error)
{
  MessageBox.Show(error.Message);
}

There is no class that contains any property to enter login/password.

I know (it’s more like I think) that works this way no login/password.

My question is:

Being a Web Service and sending in the way I demonstrate, where I would pass the login/password if classes do not have a property for such information?

There would be another shipping mode that I don’t know about?

EDITED BELOW...
Good morning.. I requested a test area to connect and send the information.
The owners of the SERVER removed the need for login and password
Now, on C# I’m having another problem..
I can send by SOAP UI informing ACTION as shown below.
inserir a descrição da imagem aqui


how should I proceed to pass this information in the code above?

  • Depends on how Webservice authentication works.

  • Btw, a tip: the reading of your publication would be much more fluid if it had less noise in it, both in the title and in the publication itself. As for the title, you can give only a brief description of the problem, no need to inform technology, because the tag system serves precisely for this purpose. Note that this is a tip from me to you, has no relation to the rules of the site or anything like.

  • Authentication and Authorization depends on how Webservice works... see if your instance of PortTypeClient does not own the property ClientCredentials, Credentials or AuthUser

  • Good afternoon LINQ.. I will check how the authentication of the webservice works... Do you know which types exist? A brief explanation to give me a NORTH and I know what to look for? : ) and Thanks for the tip of the "more fluid". I think with time and practice I can do as you describe :)

  • Good afternoon Leandro Angelo... as I spoke with LINQ I will check what kind of authentication is. In fact until then I thought it was for a property of the object.. type as you described. Porttypeclient.Clientexxx or any other property.. But if you have I didn’t find.. and I looked carefully at wsdl and nothing.. Nothing indicating the use of login/ password in any property.. Thanks for your attention :) As I asked for LINQ.. you would know the types of authentication that exist so that I can research more accurately?? :)

  • Ok... submit the service wsdl. Silly question, you are not getting the request why it is asking for credentials?

  • Good afternoon @Leandroangelo . Sending the example above returns me the message sequinte.: ERROR : Unauthorized(401) - I believe it is saying that you do not have authorization .. correct??

  • @The wsdl’s address is : https://esbdev.abbott.com:443/eProxy/service/Symphony_accountingservice_router? wsdl

  • @Ricardom.Souza There are several types, nor would you be able to list. About the writing: certainly you get better. Btw, another tip, when you quote someone in the comment you can use the @ this will cause the person to be notified =D

  • By wsdl there doesn’t seem to be any authentication in the envelope of the service, so the restriction should be by basic Authentication, restructured by IP or some key that you should pass in the header of the request... Note that in the service there is also a header object with some parameters that you are passing empty. And finally, so far you have not presented what is the error that your code is returning.

  • @Leandroangelo The error I put in the above answer.. : ) What would be by BASIC auhentication? How I would pass something through this BASIC AUTHENTICATION, in view of the code I developed?

  • Good morning @Leandroangelo .. I edited the question.. You would have some knowledge about it?

Show 7 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.