c# - Can you mimic an existing service in WCF? -


we have 3rd party vendor service , in-house service communicate it. works our in-house service, i've been asked write fall clone of our vendor's service. intention able run our clone, swap-out client end-point , allow our in-house service continue testing against clone.

is possible recreate/mimic service such existing client can communicate (without modification) if original service?

so far i’ve tried 3 things , none of them work.

1st approach

create simple service, reference 3rd party service gain access custom types , mimic [operation contract]’s.

when try communicate service following error.

a first chance exception of type 'system.servicemodel.actionnotsupportedexception' occurred in system.servicemodel.dll additional information: message action '' cannot processed @ receiver, due contractfilter mismatch @ endpointdispatcher. may because of either contract mismatch (mismatched actions between sender , receiver) or binding/security mismatch between sender , receiver. check sender , receiver have same contract , same binding (including security requirements, e.g. message, transport, none).

there no security requirements using basic http (no ssl). service model portion of config file , service behaviour class attributes below:

<system.servicemodel>     <bindings>       <basichttpbinding>         <binding name="simplebinding" />       </basichttpbinding>     </bindings>     <services>       <service behaviorconfiguration="clonebehavior" name="myclone">         <endpoint address="" binding="basichttpbinding" bindingconfiguration="simplebinding"           contract="myservice.imyservice" />         <host>           <baseaddresses>             <add baseaddress="http://localhost/clone/" />           </baseaddresses>         </host>       </service>     </services>     <behaviors>       <servicebehaviors>         <behavior name="clonebehavior">           <servicemetadata httpgetenabled="true" httpgeturl="http://localhost/clone/mex" />           <servicedebug includeexceptiondetailinfaults="false" />         </behavior>       </servicebehaviors>     </behaviors> </system.servicemodel> 

and service behaviour

[servicebehavior(name = "cloneservice",      configurationname = "myclone",      instancecontextmode = instancecontextmode.percall,      addressfiltermode = addressfiltermode.any)] public class myservice : imyservice { 

everything looks , have come first dead end.

2nd approach

get rid of interface/service contract , inherit directly interface generated in reference.cs file.

when run service up, following error

system.invalidoperationexception: operations mymethoda , mymethodb have same action (). every operation must have unique action value.

at system.servicemodel.dispatcher.immutabledispatchruntime.actiondemuxer.add(string action, dispatchoperationruntime operation) @ system.servicemodel.dispatcher.immutabledispatchruntime..ctor(dispatchruntime dispatch) @ system.servicemodel.dispatcher.dispatchruntime.getruntimecore() @ system.servicemodel.dispatcher.channeldispatcher.onopened() @ system.servicemodel.channels.communicationobject.open(timespan timeout) @ system.servicemodel.servicehostbase.onopen(timespan timeout) @ system.servicemodel.channels.communicationobject.open(timespan timeout) @ microsoft.tools.svchost.servicehosthelper.openservice(serviceinfo info)

taking @ generated interface method, decorated following attribute:

[system.servicemodel.operationcontractattribute(action="", replyaction="*")] 

my understanding msdn wcf defaults adding unique action of pattern <namespace>/<service>/<operation>[response].

if try setting action * can hit service (as expected catch / unmatched message handler), can't hit specific method.

nevertheless, manually making actions unique (and conforming above pattern), give error:

the contract ‘imyservice’ in client configuration not match name in service contract, or there no valid method in contract. …

i have defined methods in service contract , have come second dead end.

3rd approach

using wsdl.exe tool generate service wsdl. followed instructions this post generate interface , inherit it.

i’ve tried generating service using clientwsdl.wsdl /l:cs /server command , following instructions in this post.

after tidying generated code , running up, i’m original error:

a first chance exception of type 'system.servicemodel.actionnotsupportedexception' occurred in system.servicemodel.dll additional information: message action '' cannot processed @ receiver, due contractfilter mismatch @ endpointdispatcher. may because of either contract mismatch (mismatched actions between sender , receiver) or binding/security mismatch between sender , receiver. check sender , receiver have same contract , same binding (including security requirements, e.g. message, transport, none).

at each attempt have double checked config settings , updated contract @ each stage.

at stage i'm wondering if it's possible.

were ever able mimic service using wcf? find myself in similar situation i've been tasked write integration tests our method makes call vendor's web service. have preferred leverage moq write proper unit tests, i'm constrained 1) not being allowed change signature of method i'm testing, , 2) not knowing web service except send service , expected response.

@jparram's suggestion next approach.

note: have preferred have posted comment seeing i'm not answering question.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -