Wednesday, 11 September 2013

WCF Service exporting 1 Interface with 2 Implementation classes

WCF Service exporting 1 Interface with 2 Implementation classes

I'm new to WCF and C#.
I'm trying to create a WCF Service with 1 Interface (IA) with 1 method
(Do) which has 2 implementations (A1 & A2).
A silly example:
IA.cs:
namespace IA_NS
{
[ServiceContract]
public interface IA
{
[OperationContract]
int Do(B b);
}
[DataContract]
public class B
{
[DataMember]
public string b1 { get; set; }
}
}
A1.cs:
namespace A1_NS
{
public class A1 : A
{
public int Do(B b) {...}
}
}
A2.cs:
namespace A2_NS
{
public class A2 : A
{
public int Do(B b) {...}
}
}
I want my WCF Client to be able to call both classes:
Client.cs:
namespace Client_NS
{
class Program
{
static void Main(string[] args)
{
...
B myB;
if (...)
A1.Do(myB);
else
A2.Do(myB);
}
}
}
No luck ;-(
I tried putting 2 elements in my WCF-Service app.config:
<service name="A1_NS.A1" >
<endpoint address="http://localhost/A1"
contract="IA_NS.IA" />
</service>
<service name="A2_NS.A2" >
<endpoint address="http://localhost/A2"
contract="IA_NS.IA" />
contract="IA_NS.IA" />
</service>
When running the debugger - the debugging app (WCF Service Host) lets me
test the Do() method of both classes.
I can't get my Client to do it. I added Service References for both
services. Is it the Client app.config or am I misunderstanding something?

Exercise (Big-Oh): How do find intersection of two functions where n = 100 for example

Exercise (Big-Oh): How do find intersection of two functions where n = 100
for example

I am trying to understand how n^2 is faster than nlogn for n < 100 and
opposite when n >= 100. In general this is not the case but this is an
exercise that I do not want an answer for but to lead me to the right
direction. I can picture two function in a graph that intersection at n =
100 as n < 100 O(n^2) is faster and as n > 100 O(nlogn) is faster.
I came up with an^2+b and c*nlog(n)+d
The key to my understanding here is constant that makes the differences.
But what is hard is that I need to come up with constants that will
satisfy the above scenario. Is there a way or technique that is done or am
I going correctly on the wrong direction?
Original question: James and Brad are arguing about the performance of
their sorting algorithms. James claims that hisO(N logN)-time algorithm is
always faster than Brad's O(N2)-time algorithm. To settle the issue, they
implement and run the two algorithms on many randomly generated data sets.
To James' dismay, they find that if N < 100 the O(N2)-time algorithm
actually runs faster, and only when&#8232;N >= 100 the O(N logN)-time one
is better. Explain why the above scenario is possible. You may give
numerical examples.

Example of how to use bind_result vs get_result

Example of how to use bind_result vs get_result

I would like to see an example of how to call using bind_result vs.
get_result and what would be the purpose of using one over the other.
Also the pro and cons of using each.
What is the limitation of using either and is there a difference.

How to download a file from an ajax call to a controller?

How to download a file from an ajax call to a controller?

I am making a GET ajax call to an mvc controller that returns a
FileStreamResult. Now when I look at the network traffic of the browser, I
see a XMLHttpRequest being made which comes back with a 200 result.
In ie f12 tool if I go to the response body tab I see a Save as link,
which when clicked gives the correct file

How do I instead give them an option to download the file?

Is it possible to use an existing webjar in your jruby on rails applications?

Is it possible to use an existing webjar in your jruby on rails applications?

Is it possible to use an existing webjar in your jruby on rails applications?
If a webjar cannot be used directly in a JRoR application, is it possible
to access a webjar from your rails application which is deployed via .war
file to glassfish or tomcat?
I'm not very familiar with Java webjars, so I apologize if I'm not asking
the right questions here. The goal, however, is code reuse.

How to deploy War file in Fuse ESB

How to deploy War file in Fuse ESB

I have developed a webservice using Apache CXF and deployed it on Apache
Tomcat and its working fine.
Now i required to deploy it on Jboss Fuse. I tried to deploy it by copying
in deploy folder but not able to get ?wsdl and found following error in
fuse.log
16:28:49,889 | ERROR | Executor: 1 | ContextLoader | 174 -
org.springframework.web - 3.1.3.RELEASE | Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected
exception parsing XML document from ServletContext resource
[/WEB-INF/cxf-beans.xml]; nested exception is
org.springframework.beans.FatalBeanException: Class
[org.apache.cxf.jaxws.spring.NamespaceHandler] for namespace
[http://cxf.apache.org/jaxws] does not implement the
[org.springframework.beans.factory.xml.NamespaceHandler] interface at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)[105:org.springframework.beans:3.1.3.RELEASE]
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)[105:org.springframework.beans:3.1.3.RELEASE]
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)[105:org.springframework.beans:3.1.3.RELEASE]
at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)[105:org.springframework.beans:3.1.3.RELEASE]
Please guide how i can deploy it on Fuse and what kind of configuration
changes required.
Regards, imran

Failed to load the JNI Shared Library c:\APS\jdk1.5.0_22_x64/bin..\jre\bin\server\jvm.dll

Failed to load the JNI Shared Library
c:\APS\jdk1.5.0_22_x64/bin..\jre\bin\server\jvm.dll

While starting the Eclipse when ever u get above exception then
followbelow steps : 1. Here your windows on 64 bit. 2. Go to command
window and check the java version. 3. Here it will show different java
version e.g. In u'r machine u have installed java version 1.5 and same
updated in system variable but in command promt it will show u java
version as 1.6. 6. So Please go to below location in u'r system :
C:\Windows\System32 and delete or rename the java.exe and javaw.exe file.
7. Then restart the eclipse here eclipse will refer the java (version
should be compatible to 64 bit) path from system variable which is defined
. 8. And when u check the java version from command promt it will show u
the version which was installed by u.