Tuesday, September 20, 2011

WCF: enable rest operation

I need to call a WCF service through Get, Put and Post operation. And there are some settings needed  in the service contract and web.config.

Methods can be called  through the following URL:

http://ip/sitename/Service1.svc/user/post/{value}

For service contract:
 [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        [WebGet(UriTemplate = "?value={value}")]
        string GetData(int value);
        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "post/{value}")]
        string PostData(String value);
        [OperationContract]
        [WebInvoke(Method = "PUT", UriTemplate = "put/{value}")]
        string PutData(string value);
    }
For web.config:

      
          
              
              
              
          
      
     
        
            
                
            
        
        
        
          
          
        
      
    
    
  

SSH SCP put command workflow: unable to put file

I run the default SCP put command workflow in the orchestrator and the workflow finishes without any error code. But I cannot find the file in the destination.

In the API Explorer, I do some searching. I discover the description of SSHSession which is used to replace SSHCommand.



//original code
var sshCmd = new SSHCommand(ip,username,password) ;
sshCmd.putFile("C:\\orchestrator\\hoho", "//") + "||");
var error = sshCmd.getError() ;
sshCmd.disconnect();


//updated code
var sshSession = new SSHSession(ip,username);
sshSession.connectWithPassword(password);
sshSession.putFile("C:\\orchestrator\\hoho", "hoho");
sshSession.disconnect();

Saturday, July 16, 2011

Linux: loopback address

I run a java application under Linux environment and it throw an exception.

"Server failed to start: java.rmi.RemoteException: Cannot start. localhost.localdomain is a loopback address"

The problem seems related to the host file (\etc\hosts) and its content is shown below:

127.0.0.1 localhost.localdomain localhost
::1 localhost






After the configuration, everything works fine.

Thursday, July 14, 2011

OleDbConnection: insert a parameter into a query

I want to create a OleDbConnection to a excel file and create a parameterized query. An example from msdn is shown below:

string queryString = "SELECT * FROM Table1 WHERE Field1 LIKE ?";
OleDbCommand command = new OleDbCommand(queryString, connection);
command.Parameters.Add("@p1", OleDbType.Char, 3).Value = "a";
OleDbDataReader reader = command.ExecuteReader();

For your reference:
http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbparameter.aspx
http://blogs.msdn.com/b/wriju/archive/2008/01/24/ado-net-oledbcommand-parameterized-query-sequence-rule.aspx

Wednesday, June 29, 2011

JMeter: Distributed Test

I want to set up a distributed testing in my network. Then, I prepare a new vm and configure the settings. You can follow the instruction in the link below:



After the configuration, I run the ApacheJMeter.jar as normal. The next step, I click Run=>Remote Start=>127.0.0.1 and an error message is popped up: 

"Connection refused to host: 127.0.0.1;nested exception is: java.net.ConnectException: Connection refused: connect"


After my investigation, I discover something which can explain above message. If you clcik Run=>Start, the application functions fine. If you click Run=>Remote Start=>127.0.0.1, please run jmeter-server.bat. It is because the application treat the localhost as one of the slaves. 

Everything works fine when I run this bat file.

Friday, June 17, 2011

OpenXml: add reference to System.IO.Packaging

In order to use the API of OpenXML, I need to add a reference to "System.IO.Packaging" to the .Net project.

In a C# file, I cannot reference the .dll directly using "System.IO.Packaging".



Then, I  right click the Reference and then select "Add Reference..." under Solution Explorer 


But I cannot find "System.IO.Packaging" under Tab ".Net"


After my searching, I know that I need to add a reference to "WindowBase" instead of "System.IO.Packaging"


Then, I can reference successfully.



Tuesday, June 14, 2011

Jet 4.0: columns data type in Excel file

Under Jet 4.0, by default, it determine the column data type by first 8 rows.

If you want to the driver determine the data type considering all rows, you can edit the "TypeGuessRows" in Registry Editor.

Go to the Registry Editor by typing "regedit" in cmd, 


Under Registry Editor, go to HKKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Excel



Then, Edit the value "TypeGuessRows" to 0 which means consider all rows to guess data type.