c# - WCF namespace prefix -
i trying consume understand older style asmx web service third party provider, want use wcf since recommended approach newer style applications.
when add service reference application web reference (click advanced button in add service reference dialog , choose add web reference), can consume web service. works. this, however, older style method of setting web service, understand.
what want via wcf, went adding service reference without doing web reference (e.g. add service reference dialog, putting in address , clicking go). of code talk web service seems work, keep getting following exception:
system.servicemodel.communicationexception unhandled user code hresult=-2146233087 message=unrecognized message version. source=mscorlib stacktrace: server stack trace: @ system.servicemodel.channels.receivedmessage.readstartenvelope(xmldictionaryreader reader) @ system.servicemodel.channels.bufferedmessage..ctor(ibufferedmessagedata messagedata, recycledmessagestate recycledmessagestate, boolean[] understoodheaders, boolean understoodheadersmodified) @ system.servicemodel.channels.bufferedmessage..ctor(ibufferedmessagedata messagedata, recycledmessagestate recycledmessagestate) @ system.servicemodel.channels.textmessageencoderfactory.textmessageencoder.readmessage(arraysegment`1 buffer, buffermanager buffermanager, string contenttype) @ system.servicemodel.channels.messageencoder.readmessage(stream stream, buffermanager buffermanager, int32 maxbuffersize, string contenttype) @ system.servicemodel.channels.httpinput.readchunkedbufferedmessage(stream inputstream) @ system.servicemodel.channels.httpinput.parseincomingmessage(httprequestmessage httprequestmessage, exception& requestexception) @ system.servicemodel.channels.httpinput.parseincomingmessage(exception& requestexception) @ system.servicemodel.channels.httpchannelfactory`1.httprequestchannel.httpchannelrequest.waitforreply(timespan timeout) @ system.servicemodel.channels.requestchannel.request(message message, timespan timeout) @ system.servicemodel.dispatcher.requestchannelbinder.request(message message, timespan timeout) @ system.servicemodel.channels.servicechannel.call(string action, boolean oneway, proxyoperationruntime operation, object[] ins, object[] outs, timespan timeout) @ system.servicemodel.channels.servicechannel.call(string action, boolean oneway, proxyoperationruntime operation, object[] ins, object[] outs) @ system.servicemodel.channels.servicechannelproxy.invokeservice(imethodcallmessage methodcall, proxyoperationruntime operation) @ system.servicemodel.channels.servicechannelproxy.invoke(imessage message) exception rethrown @ [0]: @ system.runtime.remoting.proxies.realproxy.handlereturnmessage(imessage reqmsg, imessage retmsg) @ system.runtime.remoting.proxies.realproxy.privateinvoke(messagedata& msgdata, int32 type) @ marketvision.fulfillmentservice.fulfillmentprocessors.textwire.processor.textwireproxy.ws_companyporttype.readcompany(wsauthentication auth) @ marketvision.fulfillmentservice.fulfillmentprocessors.textwire.processor.textwireproxy.ws_companyporttypeclient.readcompany(wsauthentication auth) @ marketvision.fulfillmentservice.fulfillmentprocessors.textwire.processor.serviceagent.createcompany(string name) @ marketvision.fulfillmentservice.fulfillmentprocessors.textwire.processor.textwirefulfillmentprocessor.fulfillorders(ienumerable`1 orders) @ fulfillmentservice.services.wcf.fulfillmentservice.fulfillorders(ifulfillmentinfo fulfillmentinfo) in x:\fulfillmentservice\main\source\services\wcf\fulfillmentservice.cs:line 18 @ syncinvokefulfillorders(object , object[] , object[] ) @ system.servicemodel.dispatcher.syncmethodinvoker.invoke(object instance, object[] inputs, object[]& outputs) @ system.servicemodel.dispatcher.dispatchoperationruntime.invokebegin(messagerpc& rpc) innerexception:
i've played around fiddler , looks simple namespace problem not sure how fix. here message works when setting service web reference:
<?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:webservices2_0_0" xmlns:types="urn:webservices2_0_0/encodedtypes" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <soap:body soap:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/"> <tns:readcompany> <auth href="#id1" /> </tns:readcompany> <tns:wsauthentication id="id1" xsi:type="tns:wsauthentication"> <api_key xsi:type="xsd:string">myapikey</api_key> <code xsi:type="xsd:string">mycode</code> <keyword xsi:type="xsd:string">mykeyword</keyword> <password xsi:type="xsd:string">mypassword</password> <username xsi:type="xsd:string">myusername</username> </tns:wsauthentication> </soap:body> </soap:envelope>
and here 1 not when setting service service reference (not web reference):
<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:body s:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <q1:readcompany xmlns:q1="urn:webservices2_0_0"> <auth href="#id1"/> </q1:readcompany> <q2:wsauthentication id="id1" xsi:type="q2:wsauthentication" xmlns:q2="urn:webservices2_0_0"> <api_key xsi:type="xsd:string">myapikey</api_key> <code xsi:type="xsd:string">mycode</code> <keyword xsi:type="xsd:string">mykeyword</keyword> <password xsi:type="xsd:string">mypassword</password> <username xsi:type="xsd:string">myusername</username> </q2:wsauthentication> </s:body> </s:envelope>
there differences between 2 messages other namespaces, have in fiddler take message doesn't work , change of s: namespaces soap: , works. so, pretty sure have change namespace did fiddler , should work using wcf, not sure how that.
you should try using svcutil command line tool (open vs command prompt run it), although similar reference feature of vs different codebase. can use generate proxy, client-side types etc, service reference feature , it's pretty reliable.
Comments
Post a Comment