SOAP request authentication in VB.NET -
i'm trying write soap request 3rd party web service in vb. i've added service reference automatically added following web.config:
<basichttpbinding> <binding name="soap11"> <security mode="none"> <transport clientcredentialtype="none" proxycredentialtype="none" realm="" /> <message clientcredentialtype="username" algorithmsuite="default" /> </security> </binding> </basichttpbinding>
now have write following request:
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:header> <wsse:security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:usernametoken> <wsse:username>username</wsse:username> <wsse:password>password</wsse:password> </wsse:usernametoken> </wsse:security> </soapenv:header> <soapenv:body> <sch:request> </sch:request> </soapenv:body> </soapenv:envelope>
i don't have clue next. don't know how provide authentification details. i've done following:
dim myclient new myservicereference.client dim myrequest new myservicereference.request dim myresponse new myservicereference.response myclient.clientcredentials.username.username = "bob" myclient.clientcredentials.username.password = "dole21" myresponse = myclient.lookup(myrequest)
obviously, not lot. has produced following (according fiddler).
<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:body xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <lookup xmlns="http://example.com/schemas"/></s:body></s:envelope>
any appreciated. how add authentication headers soap request? i've tried changing
security mode="transport"
but throws "the provided uri scheme 'http' invalid; expected 'https'." error.
if service client supports constructor new servicereference.client(endpointconfigurationbyname string)
can configure stuff within application config:
<client> <endpoint address="http://someserver", binding="soap11", name="myservice"> <headers> <wsse:security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:usernametoken> <wsse:username>username</wsse:username> <wsse:password>password</wsse:password> </wsse:usernametoken> </wsse:security> </headers> </endpoint>
after doing can create new client instance providing configuration name:
dim myclient new servicereference1.client("myservice")
whenever myclient
sends soap request, send configured header along it.
you can have more 1 endpoint in configuration support several instances/stages
Comments
Post a Comment