mirror of
https://github.com/iminet/xmlrpcwsc-dotnet.git
synced 2024-11-15 04:52:37 +01:00
Merged branch develop into master
This commit is contained in:
commit
c2a9f6f237
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -30,6 +30,7 @@ $RECYCLE.BIN/
|
||||||
*.msi
|
*.msi
|
||||||
*.msm
|
*.msm
|
||||||
*.msp
|
*.msp
|
||||||
|
*.mdb
|
||||||
|
|
||||||
# Windows shortcuts
|
# Windows shortcuts
|
||||||
*.lnk
|
*.lnk
|
||||||
|
|
BIN
documents/printscreen-1.png
Normal file
BIN
documents/printscreen-1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 81 KiB |
BIN
documents/printscreen-2.png
Normal file
BIN
documents/printscreen-2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 51 KiB |
BIN
documents/printscreen-3.png
Normal file
BIN
documents/printscreen-3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.9 KiB |
|
@ -31,7 +31,7 @@ namespace sandbox {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class MainClass {
|
class MainClass {
|
||||||
|
|
||||||
public static string Url = "http://localhost:8069/xmlrpc/2", db = "odoo", pass = "admin", user = "admin";
|
public static string Url = "http://localhost:8069/xmlrpc/2", db = "odoo9", pass = "admin", user = "admin";
|
||||||
|
|
||||||
public static void TestRequestXml() {
|
public static void TestRequestXml() {
|
||||||
XmlRpcRequest request = new XmlRpcRequest("version");
|
XmlRpcRequest request = new XmlRpcRequest("version");
|
||||||
|
@ -211,74 +211,6 @@ namespace sandbox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void TestCreateRecord() {
|
|
||||||
XmlRpcClient client = new XmlRpcClient();
|
|
||||||
client.Url = Url;
|
|
||||||
client.Path = "common";
|
|
||||||
|
|
||||||
// LOGIN
|
|
||||||
|
|
||||||
XmlRpcRequest requestLogin = new XmlRpcRequest("authenticate");
|
|
||||||
requestLogin.AddParams(db, user, pass, XmlRpcParameter.EmptyStruct());
|
|
||||||
|
|
||||||
XmlRpcResponse responseLogin = client.Execute(requestLogin);
|
|
||||||
|
|
||||||
// Console.WriteLine("authenticate");
|
|
||||||
// Console.WriteLine("REQUEST: ");
|
|
||||||
// client.WriteRequest(Console.Out);
|
|
||||||
|
|
||||||
// Console.WriteLine();
|
|
||||||
// Console.WriteLine();
|
|
||||||
// Console.WriteLine("RESPONSE: ");
|
|
||||||
// client.WriteResponse(Console.Out);
|
|
||||||
|
|
||||||
Console.WriteLine();
|
|
||||||
Console.WriteLine();
|
|
||||||
Console.WriteLine("LOGIN: ");
|
|
||||||
if (responseLogin.IsFault()) {
|
|
||||||
Console.WriteLine(responseLogin.GetFaultString());
|
|
||||||
} else {
|
|
||||||
Console.WriteLine(responseLogin.GetString());
|
|
||||||
}
|
|
||||||
|
|
||||||
// CREATE
|
|
||||||
|
|
||||||
client.Path = "object";
|
|
||||||
|
|
||||||
XmlRpcRequest requestCreate = new XmlRpcRequest("execute_kw");
|
|
||||||
requestCreate.AddParams(db, responseLogin.GetInt(), pass, "res.partner", "create",
|
|
||||||
XmlRpcParameter.AsArray(
|
|
||||||
XmlRpcParameter.AsStruct(
|
|
||||||
XmlRpcParameter.AsMember("name", "Albert Einstein")
|
|
||||||
, XmlRpcParameter.AsMember("image", Convert.ToBase64String(File.ReadAllBytes("img/einstein.jpg")))
|
|
||||||
, XmlRpcParameter.AsMember("email", "albert.einstein@email.com")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
XmlRpcResponse responseCreate = client.Execute(requestCreate);
|
|
||||||
|
|
||||||
// Console.WriteLine();
|
|
||||||
// Console.WriteLine();
|
|
||||||
// Console.WriteLine("create");
|
|
||||||
// Console.WriteLine("REQUEST: ");
|
|
||||||
// client.WriteRequest(Console.Out);
|
|
||||||
|
|
||||||
// Console.WriteLine();
|
|
||||||
// Console.WriteLine();
|
|
||||||
// Console.WriteLine("RESPONSE: ");
|
|
||||||
// client.WriteResponse(Console.Out);
|
|
||||||
|
|
||||||
Console.WriteLine();
|
|
||||||
Console.WriteLine();
|
|
||||||
Console.WriteLine("READ: ");
|
|
||||||
if (responseCreate.IsFault()) {
|
|
||||||
Console.WriteLine(responseCreate.GetFaultString());
|
|
||||||
} else {
|
|
||||||
Console.WriteLine(responseCreate.GetString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void TestSearchReadRecords() {
|
public static void TestSearchReadRecords() {
|
||||||
XmlRpcClient client = new XmlRpcClient();
|
XmlRpcClient client = new XmlRpcClient();
|
||||||
client.Url = Url;
|
client.Url = Url;
|
||||||
|
@ -322,25 +254,23 @@ namespace sandbox {
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
XmlRpcParameter.AsStruct(
|
XmlRpcParameter.AsStruct(
|
||||||
XmlRpcParameter.AsMember("fields", XmlRpcParameter.AsArray("name","email"))
|
XmlRpcParameter.AsMember("fields", XmlRpcParameter.AsArray("name", "email"))
|
||||||
// ,XmlRpcParameter.AsMember("limit", 2)
|
// ,XmlRpcParameter.AsMember("limit", 2)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
XmlRpcResponse responseSearch = client.Execute(requestSearch);
|
XmlRpcResponse responseSearch = client.Execute(requestSearch);
|
||||||
|
|
||||||
// Console.WriteLine();
|
Console.WriteLine();
|
||||||
// Console.WriteLine();
|
Console.WriteLine();
|
||||||
// Console.WriteLine("search");
|
Console.WriteLine("search");
|
||||||
// Console.WriteLine("REQUEST: ");
|
Console.WriteLine("REQUEST: ");
|
||||||
// client.WriteRequest(Console.Out);
|
client.WriteRequest(Console.Out);
|
||||||
|
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("RESPONSE: ");
|
||||||
|
|
||||||
// Console.WriteLine();
|
|
||||||
// Console.WriteLine();
|
|
||||||
// Console.WriteLine("RESPONSE: ");
|
|
||||||
// client.WriteResponse(Console.Out);
|
|
||||||
|
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
|
@ -353,12 +283,80 @@ namespace sandbox {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void TestCreateRecord() {
|
||||||
|
XmlRpcClient client = new XmlRpcClient();
|
||||||
|
client.Url = Url;
|
||||||
|
client.Path = "common";
|
||||||
|
|
||||||
|
// LOGIN
|
||||||
|
|
||||||
|
XmlRpcRequest requestLogin = new XmlRpcRequest("authenticate");
|
||||||
|
requestLogin.AddParams(db, user, pass, XmlRpcParameter.EmptyStruct());
|
||||||
|
|
||||||
|
XmlRpcResponse responseLogin = client.Execute(requestLogin);
|
||||||
|
|
||||||
|
Console.WriteLine("authenticate");
|
||||||
|
Console.WriteLine("REQUEST: ");
|
||||||
|
client.WriteRequest(Console.Out);
|
||||||
|
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("RESPONSE: ");
|
||||||
|
client.WriteResponse(Console.Out);
|
||||||
|
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("LOGIN: ");
|
||||||
|
if (responseLogin.IsFault()) {
|
||||||
|
Console.WriteLine(responseLogin.GetFaultString());
|
||||||
|
} else {
|
||||||
|
Console.WriteLine(responseLogin.GetString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// CREATE
|
||||||
|
|
||||||
|
client.Path = "object";
|
||||||
|
|
||||||
|
XmlRpcRequest requestCreate = new XmlRpcRequest("execute_kw");
|
||||||
|
requestCreate.AddParams(db, responseLogin.GetInt(), pass, "res.partner", "create",
|
||||||
|
XmlRpcParameter.AsArray(
|
||||||
|
XmlRpcParameter.AsStruct(
|
||||||
|
XmlRpcParameter.AsMember("name", "Albert Einstein")
|
||||||
|
, XmlRpcParameter.AsMember("image", Convert.ToBase64String(File.ReadAllBytes("img/einstein.jpg")))
|
||||||
|
, XmlRpcParameter.AsMember("email", "albert.einstein@email.com")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
XmlRpcResponse responseCreate = client.Execute(requestCreate);
|
||||||
|
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("create");
|
||||||
|
Console.WriteLine("REQUEST: ");
|
||||||
|
client.WriteRequest(Console.Out);
|
||||||
|
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("RESPONSE: ");
|
||||||
|
client.WriteResponse(Console.Out);
|
||||||
|
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("READ: ");
|
||||||
|
if (responseCreate.IsFault()) {
|
||||||
|
Console.WriteLine(responseCreate.GetFaultString());
|
||||||
|
} else {
|
||||||
|
Console.WriteLine(responseCreate.GetString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void Main(string[] args) {
|
public static void Main(string[] args) {
|
||||||
TestRequestXml();
|
// TestRequestXml();
|
||||||
// TestResponseXml();
|
// TestResponseXml();
|
||||||
// TestReadVersion();
|
// TestReadVersion();
|
||||||
// TestReadRecords();
|
// TestReadRecords();
|
||||||
// TestCreateRecord();
|
TestCreateRecord();
|
||||||
// TestSearchReadRecords();
|
// TestSearchReadRecords();
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user