Getting following exception for our application with wildfly 9.0.1 running in cluster environment, after which wildfly became unresponsive.
It looks similar to bug:[WFLY-5697] ISPN000136: Execution error: CacheListenerException: ISPN000280: Caught exception StackOverflowError while i…, which I think has been fixed with wildfly 10. Do you know what could have triggered this ? Is ther any workaround that we can put in wildfly 9.0.1
Exception:
12-Jul-2016 21:59:26,809 ERROR [InvocationContextInterceptor] (ServerService Thread Pool -- 62) ISPN000136: Execution error: org.infinispan.commons.CacheListenerException: ISPN000280: Caught exception [java.lang.StackOverflowError] while invoking method [public void org.wildfly.clustering.web.infinispan.session.InfinispanSessionManager.removed(org.infinispan.notifications.cachelistener.event.CacheEntryRemovedEvent)] on listener instance: org.wildfly.clustering.web.infinispan.session.InfinispanSessionManager#2e3b0daa
at org.infinispan.notifications.impl.AbstractListenerImpl$ListenerInvocationImpl$1.run(AbstractListenerImpl.java:291) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.util.concurrent.WithinThreadExecutor.execute(WithinThreadExecutor.java:22) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.notifications.impl.AbstractListenerImpl$ListenerInvocationImpl.invoke(AbstractListenerImpl.java:309) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.notifications.cachelistener.CacheNotifierImpl$BaseCacheEntryListenerInvocation.doRealInvocation(CacheNotifierImpl.java:1212) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.notifications.cachelistener.CacheNotifierImpl$BaseCacheEntryListenerInvocation.invokeNoChecks(CacheNotifierImpl.java:1207) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.notifications.cachelistener.CacheNotifierImpl$BaseCacheEntryListenerInvocation.invoke(CacheNotifierImpl.java:1184) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.notifications.cachelistener.CacheNotifierImpl.notifyCacheEntryRemoved(CacheNotifierImpl.java:356) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.commands.write.RemoveCommand.notify(RemoveCommand.java:97) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.commands.write.RemoveCommand.performRemove(RemoveCommand.java:208) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.commands.write.RemoveCommand.perform(RemoveCommand.java:93) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.CallInterceptor.handleDefault(CallInterceptor.java:124) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.commands.AbstractVisitor.visitRemoveCommand(AbstractVisitor.java:49) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.commands.write.RemoveCommand.acceptVisitor(RemoveCommand.java:58) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:97) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.distribution.TxDistributionInterceptor.handleTxWriteCommand(TxDistributionInterceptor.java:306) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.distribution.TxDistributionInterceptor.visitRemoveCommand(TxDistributionInterceptor.java:86) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.commands.write.RemoveCommand.acceptVisitor(RemoveCommand.java:58) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:97) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.EntryWrappingInterceptor.invokeNextAndApplyChanges(EntryWrappingInterceptor.java:388) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.EntryWrappingInterceptor.setSkipRemoteGetsAndInvokeNextForDataCommand(EntryWrappingInterceptor.java:453) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.EntryWrappingInterceptor.visitRemoveCommand(EntryWrappingInterceptor.java:252) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.commands.write.RemoveCommand.acceptVisitor(RemoveCommand.java:58) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:97) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.locking.OptimisticLockingInterceptor.visitDataWriteCommand(OptimisticLockingInterceptor.java:147) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.locking.AbstractLockingInterceptor.visitRemoveCommand(AbstractLockingInterceptor.java:65) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.commands.write.RemoveCommand.acceptVisitor(RemoveCommand.java:58) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:97) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:111) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.commands.AbstractVisitor.visitRemoveCommand(AbstractVisitor.java:49) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.commands.write.RemoveCommand.acceptVisitor(RemoveCommand.java:58) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:97) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.TxInterceptor.enlistWriteAndInvokeNext(TxInterceptor.java:367) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.TxInterceptor.visitRemoveCommand(TxInterceptor.java:273) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.commands.write.RemoveCommand.acceptVisitor(RemoveCommand.java:58) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:97) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:111) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.commands.AbstractVisitor.visitRemoveCommand(AbstractVisitor.java:49) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.commands.write.RemoveCommand.acceptVisitor(RemoveCommand.java:58) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:97) [infinispan-core-7.2.3.Final.jar:7.2.3.Final]
Related
I'm using two applications built using C# on 4.5 .Net Framework
WPF Desktop Application
Windows Service
and want them talk to each other using IPC(Inter Process Communication) approach as they need to frequently share some data/object state based on condition.
WCF with netNamedPipeBinding seems a very flexible solution. I've created a WCF Server and Client & tested successfully hosting in Console Application.
Since this solution worked, I wanted WCF Server to be hosted in Windows Service(which is my eventual requirement).
I could host the application successfully(guess because I don't see any visible error) but I cannot connect any client to it. I've used WcfTestClient.exe tool(Visual Studio default tool) as well as tried connecting from a console application, none of them seem working, as I keep on getting the error - Cannot obtain Metadata from net.pipe://localhost/TestWCFService/mex . Details added below.
I've registered the windows service with Admin privilege and running the console app test client & WcfTestClient.exe with the same user.
Naturally, I'm missing something, appreciate your help on fixing it.
Here is the code, I'm using in Windows Service to Host WCF netNamedPipeBinding Service:
protected override void OnStart(string[] args)
{
try
{
if (wcfServiceHostObj != null)
wcfServiceHostObj.Close();
wcfServiceHostObj = new ServiceHost(typeof(TestWCFService));
wcfServiceHostObj.Open();
EventLog.WriteEntry(ServiceName, "WCF Host - Started Successfully ", EventLogEntryType.Information);
}
catch (Exception ex)
{
EventLog.WriteEntry(ServiceName, "exception raised " + ex.InnerException, EventLogEntryType.Error);
throw;
}
}
Error: Cannot obtain Metadata from net.pipe://localhost/TestWCFService/mex If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: net.pipe://localhost/TestWCFService/mex Metadata contains a reference that cannot be resolved: 'net.pipe://localhost/TestWCFService/mex'. There was no endpoint listening at net.pipe://localhost/TestWCFService/mex that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. The pipe endpoint 'net.pipe://localhost/TestWCFService/mex' could not be found on your local machine.
Here my WCF Server Config Setting:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="TestWCFServiceNetPipeBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="TestWCFServiceNetPipeBehavior"
name="WCFHostTest.WCFService.TestWCFService">
<endpoint address="net.pipe://localhost/TestWCFService" binding="netNamedPipeBinding" bindingConfiguration=""
name="TestWCFServiceNetPipeEndPoint" contract="WCFHostTest.WCFService.ITestWCFService" >
</endpoint>
<endpoint address="net.pipe://localhost/TestWCFService/mex" binding="mexNamedPipeBinding" bindingConfiguration=""
name="TestWCFServiceMexPipeEndpoint" contract="IMetadataExchange" />
<host>
<!--<baseAddresses>
<add baseAddress="net.pipe://localhost/TestWCFService" />
</baseAddresses>-->
</host>
</service>
</services>
</system.serviceModel>
For Client(which is in Console Application), I'm using inline.
Here the code
private static void testClient()
{
try
{
string address = "net.pipe://localhost/TestWCFService";
NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
EndpointAddress ep = new EndpointAddress(address);
ITestWCFService channel = ChannelFactory<ITestWCFService>.CreateChannel(binding, ep);
using (channel as IDisposable)
{
channel.SendMessage("First Message");
}
Console.ReadLine();
}
catch (Exception ex)
{
Console.Write(ex.InnerException);
Console.ReadLine();
}
The most likely reason you can't connect is because there is no service address passed into the ServiceHost constructor.
Try this in your OnStart method in your Windows service:
wcfServiceHostObj = new ServiceHost(typeof(TestWCFService),
new Uri[] { "net.pipe://localhost/TestWCFService" });
Seeing the "WCF Host - Started Successfully" only means ServiceHost didn't throw an error; it doesn't guarantee that the WCF service is listening and ready to receive messages.
Also, using the using statement with WCF clients like this:
using (channel as IDisposable)
{
channel.SendMessage("First Message");
}
is considered bad practice.
I was just learning about sqlite databases and tried a small application to just add entries into a sqlite data base ....... don't know why it doesn't work ..... I'm really frustrated and almost to lose my interest on this android stuff ....... any help is appreciated ...... Thank you in advance ..........
this is the code :
opener class
package com.example.sqlite;
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class opener {
Context cc;
SQLiteDatabase db;
public opener(Context c)
{
cc=c;
}
class SQLHelper extends SQLiteOpenHelper{
public SQLHelper(Context context) {
super(context, "app" , null, 1);
// TODO Auto-generated constructor stub
}
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE default(name TEXT, abc TEXT, ac TEXT)");
}
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS default");
onCreate(db);
}
}
public void open()
{
SQLHelper sq= new SQLHelper(cc);
db=sq.getWritableDatabase();
}
public void close()
{
db.close();
}
public long insert(String a,String b,String c)
{
ContentValues cv = new ContentValues();
cv.put("name", a);
cv.put("abc", b);
cv.put("ac", c);
return db.insert("default", null,cv);
}
}
This is the main class :
MainActivity.java
package com.example.sqlite;
import android.os.Bundle;
import android.app.Activity;
import android.app.Dialog;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends Activity {
EditText ed1;
EditText ed2;
EditText ed3;
EditText ed4;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ed1 = (EditText) findViewById(R.id.editText1);
ed2 = (EditText) findViewById(R.id.editText2);
ed3 = (EditText) findViewById(R.id.editText3);
ed4 = (EditText) findViewById(R.id.editText4);
}
public void add(View v) {
String ac = ed1.getText().toString();
String b = ed2.getText().toString();
String c = ed3.getText().toString();
opener a = new opener(this);
a.open();
long d = a.insert(ac, b, c);
a.close();
if (d != -1) {
Dialog dia = new Dialog(this);
dia.setTitle("SUCCESS");
dia.setCanceledOnTouchOutside(true);
dia.show();
}
else {
Dialog dia = new Dialog(this);
dia.setTitle("NoSuccess");
dia.setCanceledOnTouchOutside(true);
dia.show();
}
}}
And by the way sorry if it looks messy .....
The console says something like this whenever i try to insert something
07-04 12:45:57.951: I/Database(277): sqlite returned: error code = 1, msg = near "default": syntax error
07-04 12:45:57.951: E/Database(277): Failure 1 (near "default": syntax error) on 0x32a270 when preparing 'CREATE TABLE default(name TEXT, abc TEXT, ac TEXT)'.
07-04 12:45:57.961: D/AndroidRuntime(277): Shutting down VM
07-04 12:45:57.961: W/dalvikvm(277): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
07-04 12:45:58.011: E/AndroidRuntime(277): FATAL EXCEPTION: main
07-04 12:45:58.011: E/AndroidRuntime(277): java.lang.IllegalStateException: Could not execute method of the activity
07-04 12:45:58.011: E/AndroidRuntime(277): at android.view.View$1.onClick(View.java:2072)
07-04 12:45:58.011: E/AndroidRuntime(277): at android.view.View.performClick(View.java:2408)
07-04 12:45:58.011: E/AndroidRuntime(277): at android.view.View$PerformClick.run(View.java:8816)
07-04 12:45:58.011: E/AndroidRuntime(277): at android.os.Handler.handleCallback(Handler.java:587)
07-04 12:45:58.011: E/AndroidRuntime(277): at android.os.Handler.dispatchMessage(Handler.java:92)
07-04 12:45:58.011: E/AndroidRuntime(277): at android.os.Looper.loop(Looper.java:123)
07-04 12:45:58.011: E/AndroidRuntime(277): at a
android.app.ActivityThread.main(ActivityThread.java:4627)
07-04 12:45:58.011: E/AndroidRuntime(277): at java.lang.reflect.Method.invokeNative(Native Method)
07-04 12:45:58.011: E/AndroidRuntime(277): at java.lang.reflect.Method.invoke(Method.java:521)
07-04 12:45:58.011: E/AndroidRuntime(277): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-04 12:45:58.011: E/AndroidRuntime(277): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-04 12:45:58.011: E/AndroidRuntime(277): at dalvik.system.NativeStart.main(Native Method)
07-04 12:45:58.011: E/AndroidRuntime(277): Caused by: java.lang.reflect.InvocationTargetException
07-04 12:45:58.011: E/AndroidRuntime(277): at com.example.sqlite.MainActivity.add(MainActivity.java:31)
07-04 12:45:58.011: E/AndroidRuntime(277): at java.lang.reflect.Method.invokeNative(Native Method)
07-04 12:45:58.011: E/AndroidRuntime(277): at java.lang.reflect.Method.invoke(Method.java:521)
07-04 12:45:58.011: E/AndroidRuntime(277): at android.view.View$1.onClick(View.java:2067)
07-04 12:45:58.011: E/AndroidRuntime(277): ... 11 more
07-04 12:45:58.011: E/AndroidRuntime(277): Caused by: android.database.sqlite.SQLiteException: near "default": syntax error: CREATE TABLE
default(name TEXT, abc TEXT, ac TEXT)
07-04 12:45:58.011: E/AndroidRuntime(277): at android.database.sqlite.SQLiteDatabase.native_execSQL(Native Method)
07-04 12:45:58.011: E/AndroidRuntime(277): at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1727)
07-04 12:45:58.011: E/AndroidRuntime(277): at com.example.sqlite.opener$SQLHelper.onCreate(opener.java:29)
07-04 12:45:58.011: E/AndroidRuntime(277): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:106)
07-04 12:45:58.011: E/AndroidRuntime(277): at com.example.sqlite.opener.open(opener.java:45)
Thanks in advance
DEFAULT is an SQL keyword that must be quoted every time it is used in SQL statements:
db.execSQL("CREATE TABLE \"default\"(name TEXT, abc TEXT, ac TEXT)");
...
db.execSQL("DROP TABLE IF EXISTS \"default\"");
...
db.insert("\"default\"", null, cv);
You might be better of using another name.
we can pass String as
Intent returnIntent = new Intent();
returnIntent.putExtra("SelectedRadio", selectedRadio);
But if I want to pass Calendar object then how to pass it from one activity
to another?
Thanks in advance.
This is my First Activity:
public class MyCalendar extends Activity {
public Calendar myCal;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_calendar);
goCal= (ImageButton)findViewById(R.id.imageButton1);
myCal = Calendar.getInstance();
goCal.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent i = new Intent(MyCalendar.this, MainActivity.class);
i.putExtra("calendar", myCal);
startActivity(i);
});
}
}
This is my second Activity:
public class MainActivity extends Activity {
Intent myIntent;
Calendar today = (Calendar) myIntent.getExtras().getSerializable("calendar");
...
}
what is my fault. Why my app closed when i click goCal button. pls help me.. I am a new one..
my logcat:
01-09 18:55:50.338: W/dalvikvm(4252): threadid=1: thread exiting with uncaught exception (group=0xb5f41288)
01-09 18:55:50.338: E/AndroidRuntime(4252): FATAL EXCEPTION: main
01-09 18:55:50.338: E/AndroidRuntime(4252): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.mycalendar/com.example.mycalendar.MainActivity}: java.lang.NullPointerException
01-09 18:55:50.338: E/AndroidRuntime(4252): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
01-09 18:55:50.338: E/AndroidRuntime(4252): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
01-09 18:55:50.338: E/AndroidRuntime(4252): at android.app.ActivityThread.access$600(ActivityThread.java:130)
01-09 18:55:50.338: E/AndroidRuntime(4252): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
01-09 18:55:50.338: E/AndroidRuntime(4252): at android.os.Handler.dispatchMessage(Handler.java:99)
01-09 18:55:50.338: E/AndroidRuntime(4252): at android.os.Looper.loop(Looper.java:137)
01-09 18:55:50.338: E/AndroidRuntime(4252): at android.app.ActivityThread.main(ActivityThread.java:4745)
01-09 18:55:50.338: E/AndroidRuntime(4252): at java.lang.reflect.Method.invokeNative(Native Method)
01-09 18:55:50.338: E/AndroidRuntime(4252): at java.lang.reflect.Method.invoke(Method.java:511)
01-09 18:55:50.338: E/AndroidRuntime(4252): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
01-09 18:55:50.338: E/AndroidRuntime(4252): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
01-09 18:55:50.338: E/AndroidRuntime(4252): at dalvik.system.NativeStart.main(Native Method)
01-09 18:55:50.338: E/AndroidRuntime(4252): Caused by: java.lang.NullPointerException
01-09 18:55:50.338: E/AndroidRuntime(4252): at com.example.mycalendar.MainActivity.<init>(MainActivity.java:44)
01-09 18:55:50.338: E/AndroidRuntime(4252): at java.lang.Class.newInstanceImpl(Native Method)
01-09 18:55:50.338: E/AndroidRuntime(4252): at java.lang.Class.newInstance(Class.java:1319)
01-09 18:55:50.338: E/AndroidRuntime(4252): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
01-09 18:55:50.338: E/AndroidRuntime(4252): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
01-09 18:55:50.338: E/AndroidRuntime(4252): ... 11 more
Without sending calendar obj, it will work fine.. Then How to pass Calendar object from one activity to another?
we know Calander implements Serializable interface so, you can send it as a extra in the intent.
Intent i=new Intent(context,Home.class);
Calendar c=Calendar.getInstance();
i.putExtra("calobject", c);
startActivity(i);
and you can get it using this code
Calendar cal=(Calendar) getIntent().getSerializableExtra("calobject");
Here is the screenshot of debugged code it goes smoothly without any exception
I hope this will help you
Since Calendar implements Serializable you can simply do the following:
Calendar cal;
<calendar initialization>
intent.putExtra("calendar", cal);
Then for retrieving:
Calendar cal;
cal = (Calendar) intent.getSerializableExtra("calendar");
I have a WCF service, which implements interface PosData.ISampleService in class PosData.SampleService. The service is self hosted and the start up code looks like this:
ServiceHost serviceHost = new ServiceHost(typeof(SampleService), new Uri("http://localhost:8080/sample"));
serviceHost.Open();
Console.WriteLine("Service started.");
Console.ReadLine();
The app.config contains the following lines:
<services>
<service name="PosData.SampleService">
<endpoint address="http://localhost:8080/sample" contract="PosData.ISampleService" kind="webHttpEndpoint"/>
</service>
</services>
I would like to get rid of the App.config configuration, but I have no idea how to configure webHttpEndpoint via code. How can I do that?
Use WebServiceHost instead of ServiceHost.
Is it possible to create a single .svc file (WCF Service) that I can upload to my server and test if it correctly handles WCF files? i.e. it is configured to host WCF services.
(I have a IIS6 box that I have to test)
You can use inline coding in your svc file:
%# ServiceHost Language="C#" Debug="true" Service="MyService.MyService" %>
using System;
using System.Runtime.Serialization;
using System.ServiceModel;
namespace MyService
{
[ServiceContract]
public interface IMyService
{
[OperationContract]
int MyMethod(int x, int y);
}
public class MyService : IMyService
{
public int MyMethod(int x, int y)
{
return ((x + y) * 2);
}
}
}
But you will need also a web.config file and a virtual directory configured on your web server:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="false" />
</system.web>
<system.serviceModel>
<services>
<service name="MyService.MyService">
<endpoint address="" binding="wsHttpBinding" contract="MyService.IMyService" />
</service>
</services>
</system.serviceModel>
</configuration>
But basically if your web server has IIS 6.0 and .NET 3.0 installed then you should have no problems running WCF services on it.