Could not find endpoint element as referring to main project config settings - vb.net

Wonder if anyone can help me as i'm getting the following error 'Could not find endpoint element'.
My setup is similar to the following - A main project vb.net (Starts with say a login.exe that in turn uses class libraries to then do things such as set the menu navigation system which proceeds to call several winform class libraries) One of my winform class library calls another class library which contains some logic that will then in turn call a class library that has the service reference to a WCF service and will handle the WCF service reference function calls.
So if i run my winform as a standalone exe rather than a class library contained in the above setup everything works fine with connecting to the web service contained within the class libraries because i have added the <system.serviceModel> reference information to my winforms app.config as per the below thread suggested.
"Could not find endpoint element with name..."
My issue is that once i turn my winform back to a class library and include in my main project to be called it never finds the the <system.serviceModel> reference contained within my winform .dll as i'm lead to believe by again by the above linked post it will use the main project app.config not my winforms configuration.
What im trying to get at is I don't really want to add the <system.serviceModel> information contained in the app.config of my winform dll to the starting login.exe(being the program that starts the chain) as that just seems messy and just strikes me i must be doing somthing wrong in the first place. Is there a way to use the setting from my winform class rather than going all the back back through to the main project??.
I hope that makes some sort of sense any help would be greatly appreciated as really stuck as a wcf newbie, thanks in advance

Personally I don't think it's messy, that is generally how these things are done there is an application configuration file for your main you only have one copy of your main and usually your application is installed only once meanwhile you could have lots of copies of your DLL used by many apps... The configuration file will usually always contain settings that pertain to that one application meanwhile a DLL could be used by multiple applications. In short you should use the main app.config.
In any case to answer your question you could read in the app.config of the DLL in like any normal file parse it and programmatically setup the end-points as described here:
How to: Create a Service Endpoint in Code

Related

Consuming web service using wsdl in Domino

We use web service Consumers\ Providors quite a bit in our application, both LS and java design elements.
I have a web service (wcf) wsdl that I am trying to import into a LotusScript Web Consumer design element and when saving I am getting the following error:
Not a member: INVOKE
...on line indicated below.
Function GetCopyDestinations(service As XSD_STRING, ocsCode As XSD_STRING, Fault1 As InteropErrorInfoStruct_n1) As ArrayOfInteropMessageDestination_n1
Set GetCopyDestinations = Service.Invoke("GetCopyDestinations", service, ocsCode, Fault1) <<<<=====ERROR ON THIS LINE
End Function
I take this to be that the wsdl --> Web service classes transformer does not like the structure of the wsdl...? I work with the developer who is creating the service we are consuming, so I can get the structure changed, but, from error above, I am not really sure where to start. I assume this means it does not think the Object Service has the method .Invoke().
I've had a look in the file: lsxsd.lss, which LS web service elements include. The "stub" class in the LS web service inherits from PortTypeBase which is in the lsxsd.lss file, PortTypeBase does not have an invoke() method, so I am not quite sure how\ where this method is inherited from. Other LS web services we use successfully, have exactly the same structure, so it would appear this is correct.
The only thing I can think of is to get my colleague to strip the wsdl back to bare bones, then add 1 method, see if it imports, add another, see if it imports, etc.
As a side note, I tried to import the ws into a java consumer, it imports fine. I then construct the stub in exactly the same way I do for all our other java consumer services, which it appears to do successfully. When I run my test harness agent, the stub is created, but it errors when trying to run any of the actions:
java.rmi.RemoteException: No operation description was found for the service
I take this to mean, it can't find the action in the wsdl file, or something similar...? The end point url and PortName appear correct if I output as it is running.
As a side note to this...the service I am attempting to consume above, we have a version working in production now, it is in a LS web consumer, but new one has had new actions added. For a sanity check, I then imported the "live" wsdl...which we know works...into a LS web consumer design element and run a test harness agent, works as expected...good. Then I imported "live" wsdl into a java consumer design element. When running the service, we get the same error...!?
java.rmi.RemoteException: No operation description was found for the service
So now I'm really, really confused. I would like to post the wsdl here, but I think NDA etc., will not allow me, but if it's any help, I am constructing the stub as follows:
ITKInteropV10Stub stub = (ITKInteropV10Stub) new ITKInteropServiceV10_ServiceLocator().getITKInteropV10();
This is a similar stub constructor pattern to all other java web services I consume.
I have been googling\ searching for a couple of days now, searching for errors listed above, I'm really struggling to find a way forward.
Ideally, solving the import in the LS web consumer would work best, since back end logic is currently in LS Script libs which will access this service. If I get it working in java, that's fine as well, it just makes the retrieval of data from the Web Service into the LS libs a bit more complex.
Any comments\ suggestion would be welcomed with open arms!
Regards
Nick
LotusScript is not case sensitive. You have a variable called "service" of XSD_STRING and another object called "Service" which looks like it might be a NotesWebServiceEngine object? (internal LS object).

Rewriting a dll file when using MEF and WCF

On my current project, I'm sending dll files to clients using a WCF service.
The dll files contain UserControls which the clients use to visualize data.
However, sometimes new UserControls are introduced by the service, without the clients knowing about this. When this happend, I send the new dll file to the clients so they have the latest version of the UserControls.
However, when I want to write this new dll file on the clients HD (using a FileStream), I get an exception saying that the file is used by another process (of course, the clients always have an assembly version of the UserControls on their HD, so this has to be overwriten).
Is there any way to overwrite this file without getting an error? I'm using MEF to read the assembly files in the client project. To send the assembly file to the clients, I just send the filename as a string and the file's content in a byte array.
This is usually done with Shadow Copying, but I can't find anything definitive as to whether it works with MEF.
If its acceptable for your new control to be loaded on closing and re-opening the application, then you can copy all your plugins prior to composing with MEF.
Here is a blog post with somebody essentially trying MEF + Shodow Copy, and a particularly relevant comment.
The fundamental problem here is that
.NET doesn't support dynamic assembly
unloading. You could reload the
assembly, but you would never be able
to recover the memory used by the old
one

questions about using MEF in a WCF service

I'm just starting to play with MEF and have a couple questions.
1) I wrote a WCF service that takes in some xml and passes the xml off to a parser. The parsers are composed using MEF. (metadata in the xml lets me determine which parser to use). I can add a new parser, and support new XML, by just dropping the dll in a directory. That part all works. But, WCF services can be instantiated multiple times, I want my parser catalog to be static, that is, if multiple instances of my service are spun up, and they get the same XML, I only need one instance of the parser running, they are written to be thread safe. I can't seem to configure MEF to do this. Anyone know how?
2) I can drop in a new parser into the directory and a catalog refresh will automatically discover it, that works great. But if I try to drop a modified dll into the directory, and that parser has been activated in the service, I get an error saying the file is in use. Is there a way to override this?
1) It sounds like you should make your MEF container and catalogs static so they only get created once. Make sure you specify that the CompositionContainer should be thread safe by using the constructor with the isThreadSafe parameter and setting it to true.
2) You can enable shadow copying which will prevent the file from being locked when the DLL is loaded. However, you can't unload DLLs from an AppDomain in .NET, and furthermore it is not safe to recompose a CompositionContainer that can be used on multiple threads. In other words, using the isThreadSafe parameter only makes the container thread-safe for "reading"/pulling exports from the container, not modifying it via composition/recomposition.
So if you want to add a new parser it's probably best to restart the service.

WCF service reference update

Right now we have around 5 service reference added to our projects in a single solution.
I am force to add service reference even for projects having indirect dependencies calling service methods. Is there a way to get around for this situation.
For every single change in the service method, I have to update every single service reference to effect those changes. It is very time consuming too.
I am just wondering, is there any way i cam manage these things globally by making single service reference for the whole solution.
help appreciated.....:)
You should be able to use the svcutil.exe command line utility to generate a single service file (.cs file for example) from multiple service URL's. The nice thing about this is that you can share clinet-side DTO's and message types accross services if they have the same schema.
SvcUtil Reference: http://msdn.microsoft.com/en-us/library/aa347733.aspx
In regards to the requirement of adding the service reference to projects with indirect dependencies. You should probably not consume the service reference and related types directly from your service client. To improve maintainability and adaptability, you should wrap your service reference(s) in a facade. The facade would map between local types and service reference types, and give you much more agility in terms of responding to service changes. You would then only need to have the service references in a single location (preferably an independent project) along with the facade. The facade, which should change infrequently, will buffer you from the issues you are currently having with your service references.
You won't be able to get a single reference if you have multiple service, unfortunately.I stand corrected - see jrista's answer.
What you could do is create and update the service references automatically: instead of adding them manually in Visual Studio using Add Service Reference check out the svcutil.exe command line tool which will basically do the same thing.
Since it's a command line tool, you can have it run as e.g. part of your continuous build and update the necessary proxy client files every time you build the app.
Check out these additional links for tutorials and explanations about the details of using svcutil.exe:
http://msdn.microsoft.com/en-us/library/ms734712.aspx
http://asadsiddiqi.wordpress.com/2008/10/25/how-to-generate-wcf-client-proxy-class-using-svcutilexe/
http://www.xvpj.net/2008/03/08/wcf-step-by-step-tutorial/
Marc

Add Service Reference to WCF Service within Same Project

Is it an acceptable programming practice to add a Service Reference to a Project where the Service being referenced is defined within the same VS Project? (Service and Service Reference are in the same Project)
example:
MyWebAppProj
-Services
--MyService
-Service References
--MyServiceServiceReference.MyServiceClient
-Default.aspx.cs uses MyServiceServiceReference.MyServiceClient
The rational behind this is that a Silverlight App may be added to the Project. If it is, we would have to expose all the Business Logic methods through a service layer, so why not just do that first and use them everywhere to stay standardized between web pages and Silverlight pages.
I can't see why you would want to do that at all.
If you're already inside the same project as the service, at the very least you've already got access to all the service/data contracts, so really, calling the service is already very, very easy. You can either use a ChannelFactory directly, or write your own custom ClientBase<T>-derived client proxy class (which is trivial), there's no reason why you'd want to add service reference in this case.
Furthermore, if you added a service reference, you'd then be stuck with a bunch of duplicate definitions in the same project, which makes little sense (yes, you can isolate the generated code into a separate namespace, but still).