c# - BasicHttpBinding equivalent CustomBinding using WCF Client and PHP WebService -


i running visual studio 2008 unit test c# webservice php using wcf , received following error:

system.servicemodel.security.messagesecurityexception: http request unauthorized client authentication scheme 'anonymous'. authentication header received server 'ntlm,basic realm="(null)"'. ---> system.net.webexception: remote server returned error: (401) unauthorized..

i using windows xp sp3 machine, unit test vs 2008 , wcf connect php webservice.

i have no control php webservice. cannot modify (neither configuration security).

here config file client use webservice php:

 <system.servicemodel>      <extensions>       <bindingelementextensions>         <add name="customtextmessageencoding"              type="company.integracioneasyvista.customtextencoder.customtextmessageencodingelement,company.integracioneasyvista.customtextencoder, version=1.0.0.0, culture=neutral, publickeytoken=9744987c0853bf9e" />       </bindingelementextensions>      </extensions>           <bindings>                <custombinding>                     <binding name="iso8859binding">                           <customtextmessageencoding messageversion="soap11wsaddressing10"                                 encoding="iso-8859-1" />                           <httptransport />                     </binding>               </custombinding>         </bindings>         <client>               <endpoint address="http://serverphp/webservice/smobridge.php"                     binding="custombinding" bindingconfiguration="iso8859binding"                     contract="serviceeasyvista.webserviceporttype" name="easyvistasvcendpoint" />         </client>     </system.servicemodel> 

really, use c# code:

var endpointaddress = config.appsettings.settings[easyvistasvcendpointaddress].value; var endpoint = new system.servicemodel.endpointaddress(endpointaddress);  var endpointbinding = new system.servicemodel.channels.custombinding(); endpointbinding.name = "iso8859binding";  var bindingelement = new  integracioneasyvista.customtextencoder.customtextmessagebindingelement();  bindingelement.encoding = "iso-8859-1"; bindingelement.messageversion = system.servicemodel.channels.messageversion.soap11wsaddressing10; // "soap11wsaddressing10"  endpointbinding.elements.add(bindingelement);  var transportbinding = new httptransportbindingelement(); endpointbinding.elements.add(transportbinding);  configurarbinding(endpointbinding);  var svcclient = new webserviceporttypeclient(endpointbinding, endpoint); return svcclient; 

update: tests

i add line:

transportbinding.authenticationscheme = system.net.authenticationschemes.negotiate; 

i error: http request unauthorized client authentication scheme 'anonymous'. authentication header received server 'ntlm,basic realm="(null)"'

i add line:

transportbinding.authenticationscheme = system.net.authenticationschemes.basic; 

i thiserror:

system.servicemodel.communicationobjectfaultedexception: el objeto de comunicación, system.servicemodel.channels.servicechannel, no se puede usar para la comunicación porque se encuentra en el estado faulted.

//server stack trace: // en system.servicemodel.channels.communicationobject.close(timespan timeout)

i add line:

 transportbinding.authenticationscheme = system.net.authenticationschemes.ntlm; 

i thiserror:

/exception = system.servicemodel.communicationexception: versión de mensaje no reconocida.

//server stack trace: // en system.servicemodel.channels.receivedmessage.readstartenvelope(xmldictionaryreader reader)

// en system.servicemodel.channels.streamedmessage..ctor(xmldictionaryreader reader, int32 maxsizeofheaders, messageversion desiredversion)

// en system.servicemodel.channels.message.createmessage(xmldictionaryreader envelopereader, int32 maxsizeofheaders, messageversion version)

// en system.servicemodel.channels.message.createmessage(xmlreader envelopereader, int32 maxsizeofheaders, messageversion version)

// en customtextencoder.customtextmessageencoder.readmessage(stream stream, int32 maxsizeofheaders, string contenttype) en e:\tfs\pro\customtextencoder\customtextmessageencoder.cs:línea 66

// en system.servicemodel.channels.messageencoder.readmessage(stream stream, int32 maxsizeofheaders)

// en customtextencoder.customtextmessageencoder.readmessage (arraysegment`1 buffer, buffermanager buffermanager, string contenttype) en e:\tfs\pro\customtextencoder\customtextmessageencoder.cs:línea 60

// en system.servicemodel.channels.messageencoder.readmessage(stream stream, buffermanager buffermanager, int32 maxbuffersize, string contenttype)

// en system.servicemodel.channels.httpinput.readchunkedbufferedmessage(stream inputstream)

i think, following right configuration (if basichttpbinding)

<security mode="transportcredentialonly">     <transport clientcredentialtype="basic" /> </security> 

web service of wcf in basichttpbinding might not flexible enough. custombinding name describes alllows users design own web service binding.

i need use custombinding , securitymode (like basichttpbinding): wcf basichttpbinding equivalent custombinding

i need security mode: transportcredentialonly, basic, http transport , encoding="iso-8859-1"

http://www.codemeit.com/security/wcf-basichttpbinding-equivalent-custombinding.html

http://social.msdn.microsoft.com/forums/en/wcf/thread/6cefadf1-9939-4f3b-a502-2d79a30c7d3a

http://offroadcoder.com/2008/03/23/callingyournusoapphpwebservicefromwcf.aspx

http://msdn.microsoft.com/en-us/library/ms731092(v=vs.90).aspx

i try again using configuration, , error:

svcpro.clientcredentials.username.username = "my user"; svcpro.clientcredentials.username.password = "xxxx"; 

config:

<custombinding>  <binding name="iso8859binding">     <customtextmessageencoding messageversion="soap11wsaddressing10"        encoding="iso-8859-1" />      <!--<textmessageencoding messageversion="soap11" />-->     <!--<httptransport />-->     <httptransport authenticationscheme="basic" />  </binding>  </custombinding> 

the error (innerexception null):

error: unrecognized message version

tipo: system.servicemodel.communicationexception mensaje: versión de mensaje no reconocida. stacktrace: server stack trace:

en system.servicemodel.channels.receivedmessage.readstartenvelope(xmldictionaryreader reader)

en system.servicemodel.channels.streamedmessage..ctor(xmldictionaryreader reader, int32 maxsizeofheaders, messageversion desiredversion)

en system.servicemodel.channels.message.createmessage(xmldictionaryreader envelopereader, int32 maxsizeofheaders, messageversion version)

en system.servicemodel.channels.message.createmessage(xmlreader envelopereader, int32 maxsizeofheaders, messageversion version)

en reale.integracioneasyvista.customtextencoder.customtextmessageencoder.readmessage(stream stream, int32 maxsizeofheaders, string contenttype) en e:\integracioneasyvista\customtextencoder\customtextmessageencoder.cs:línea 66

en system.servicemodel.channels.messageencoder.readmessage(stream stream, int32 maxsizeofheaders) en reale.integracioneasyvista.customtextencoder.customtextmessageencoder.readmessage(arraysegment`1 buffer, buffermanager buffermanager, string contenttype) en e:\integracioneasyvista\customtextencoder\customtextmessageencoder.cs:línea 60

en system.servicemodel.channels.messageencoder.readmessage(stream stream, buffermanager buffermanager, int32 maxbuffersize, string contenttype)

en system.servicemodel.channels.httpinput.readchunkedbufferedmessage(stream inputstream)

en system.servicemodel.channels.httpinput.parseincomingmessage(exception& requestexception)

en system.servicemodel.channels.httpchannelfactory.httprequestchannel.httpchannelrequest.waitforreply(timespan timeout)

en system.servicemodel.channels.requestchannel.request(message message, timespan timeout)

en system.servicemodel.dispatcher.requestchannelbinder.request(message message, timespan timeout)

en system.servicemodel.channels.servicechannel.call(string action, boolean oneway, proxyoperationruntime operation, object[] ins, object[] outs, timespan timeout)

en system.servicemodel.channels.servicechannel.call(string action, boolean oneway, proxyoperationruntime operation, object[] ins, object[] outs)

en system.servicemodel.channels.servicechannelproxy.invokeservice(imethodcallmessage methodcall, proxyoperationruntime operation)

en system.servicemodel.channels.servicechannelproxy.invoke(imessage message)

more info: part of wdsl of service.php

<?xml version="1.0" encoding="iso-8859-1" ?>   <definitions  xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:xsd="http://www.w3.org/2001/xmlschema"  xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"  xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:si="http://soapinterop.org/xsd"  xmlns:tns="http://192.168.110.50/webservice" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"  xmlns="http://schemas.xmlsoap.org/wsdl/" targetnamespace="http://192.168.110.50/webservice">  <types>  <xsd:schema targetnamespace="http://192.168.110.50/webservice">   <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />    <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />    </xsd:schema>   </types> 

your php service requires authentication client doesn't send any. change custom binding support authentication. can set authentication in httptransport element:

<httptranposrt authenticationscheme="..." /> 

use basic or negotiate. basic require provide client credentials when communicating service. negotiate require both service , client in same domain.


Comments

Post a Comment

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

sql server - python to mssql encoding problem -

windows - Python Service Installation - "Could not find PythonClass entry" -