vb.net - WCF client side authentication -
i'm totatally newby in consuming wcf services... reading "professional wcf 4 windows communication foundation .net 4" more server base related client consuming... so, have connect web service post data , response performed action...
i had wsdl address reference (obviously user name , password) no additional info/docs... in vb 2012, referenced web reference , got proxy built... config is
<?xml version="1.0" encoding="utf-8"?> <configurationsnapshot xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns="urn:schemas-microsoft-com:xml-wcfconfigurationsnapshot"> <behaviors /> <bindings> <binding digest="system.servicemodel.configuration.basichttpbindingelement, system.servicemodel, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089:<?xml version="1.0" encoding="utf-16"?><data name="gestionecheckinv1implservicesoapbinding"><security mode="transport" /></data>" bindingtype="basichttpbinding" name="gestionecheckinv1implservicesoapbinding" /> <binding digest="system.servicemodel.configuration.basichttpbindingelement, system.servicemodel, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089:<?xml version="1.0" encoding="utf-16"?><data name="gestionecheckinv1implservicesoapbinding1" />" bindingtype="basichttpbinding" name="gestionecheckinv1implservicesoapbinding1" /> </bindings> <endpoints> <endpoint normalizeddigest="<?xml version="1.0" encoding="utf-16"?><data address="https://rerprod.turitweb.it/ws/checkinv1" binding="basichttpbinding" bindingconfiguration="gestionecheckinv1implservicesoapbinding" contract="servicereference1.gestionecheckinv1impl" name="gestionecheckinv1implport" />" digest="<?xml version="1.0" encoding="utf-16"?><data address="https://rerprod.turitweb.it/ws/checkinv1" binding="basichttpbinding" bindingconfiguration="gestionecheckinv1implservicesoapbinding" contract="servicereference1.gestionecheckinv1impl" name="gestionecheckinv1implport" />" contractname="servicereference1.gestionecheckinv1impl" name="gestionecheckinv1implport" /> </endpoints> </configurationsnapshot>
so, in code, wrote
dim address new system.servicemodel.endpointaddress("https://rerprod.turitweb.it/ws/checkinv1") dim binding system.servicemodel.basichttpbinding = new system.servicemodel.basichttpbinding() binding.opentimeout = new timespan(0, 0, 5) binding.closetimeout = new timespan(0, 0, 5) binding.sendtimeout = new timespan(0, 0, 5) binding.receivetimeout = new timespan(0, 0, 5) binding.security.mode = system.servicemodel.basichttpsecuritymode.transport dim serviceclient new servicereference1.gestionecheckinv1implclient(binding, address) dim credentialbehaviour = serviceclient.endpoint.behaviors.find(of system.servicemodel.description.clientcredentials)() credentialbehaviour.username.username = "myusername" credentialbehaviour.username.password = "mypassword" serviceclient.open() 'loaded object model accordingly no problem dim daymov new servicereference1.inviamovimentazione(daymovements) 'and perform post action expecting results dim results list(of servicereference1.risultatogiorno) = serviceclient.inviamovimentazione(daymov.movimentazione).tolist
but here code fails in serviceclient.inviamovimentazione(...) method "the http request forbidden client authentication scheme 'anonymous'." exception...
following channelfactory credentials + object read only indication, evev tried complete substitution of credential behaviour as
dim credentialbehaviour = serviceclient.endpoint.behaviors.find(of system.servicemodel.description.clientcredentials)() dim logincredentials system.servicemodel.description.clientcredentials = new system.servicemodel.description.clientcredentials() logincredentials.username.username = "myusername" logincredentials.username.password = "mypassword" serviceclient.endpoint.behaviors.remove(credentialbehaviour) serviceclient.endpoint.behaviors.add(logincredentials)
with no luck... service provider not available provide further info if i'm first user of service, and, again, i'm totally newby in wcf, i've no clue i'm doing wrong...
any hint??
tia
andrea
Comments
Post a Comment