Wednesday, April 12, 2017
Hi! I said No! No! No more computing for a while....shit....I'm back to computing (everything in security is computing Elsa grow up!, So, I have here something it looks like the bird shitting on the cables corrosive shit :) Ok why am I doing this again, because industrial systems might have several SCADA type, let's imagine that the energy grid has this CANopen network (control system for multiple microcontrollers ant their use in automation) and so the protocol is SoupSocket that actually "SoupSocket is libsoup's TCP socket type. While it is primarily intended for internal use, SoupSockets are exposed in the API in various places, and some of their methods (eg, soup_socket_get_remote_address()) may be useful to applications." but besides this link, take a look at the comment bellow
Subscribe to:
Post Comments (Atom)
kuttikrishna...
How to get SOAP Message From .svc file methood
Peter pi - M...
Re: How to get SOAP Message From .svc file methood
At the client try using
class Client { static void Main() { // Create a client CalculatorClient client = new CalculatorClient(); String RequestAction = "http://test/Message_RequestAction"; using (new OperationContextScope(client.InnerChannel)) { // Call the Sum service operation. int[] values = { 1, 2, 3, 4, 5 }; MessageHeader msgHeader = MessageHeader.CreateHeader("ClientID", "ns", "1098", false); OperationContext.Current.OutgoingMessageHeaders.Add(msgHeader); Message request = Message.CreateMessage(OperationContext.Current.OutgoingMessageHeaders.MessageVersion, RequestAction, values); Message reply = client.ComputeSum(request); int response = reply.GetBody ();
Console.WriteLine("Sum of numbers passed (1,2,3,4,5,1098) = {0}", response); }
//Closing the client gracefully closes the connection and cleans up resources
client.Close();
Console.WriteLine();
Console.WriteLine("Press to terminate client." );
Console.ReadLine();
}
}
// Define a service contract. [ServiceContract(Namespace="http://Microsoft.Samples.Untyped")] public interface ICalculator { [OperationContract(Action = CalculatorService.RequestAction, ReplyAction = CalculatorService.ReplyAction)] Message ComputeSum(Message request); } // Service class which implements the service contract. public class CalculatorService : ICalculator { // Perform a calculation. public const String ReplyAction = "http://test/Message_ReplyAction"; public const String RequestAction = "http://test/Message_RequestAction"; public Message ComputeSum(Message request) { //The body of the message contains a list of numbers which will be read as a int[] using GetBody
int result = 0;
int[] inputs = request.GetBody<int[]>();
foreach (int i in inputs)
{
result += i;
}
MessageHeaders messageHeaders = OperationContext.Current.IncomingMessageHeaders; int headerIndex = messageHeaders.GetHeader ("ClientID", "ns"); result += headerIndex; Message response = Message.CreateMessage(request.Version, ReplyAction, result);
return response;
}
}
Peter
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework
kuttikrishna...
Re: How to get SOAP Message From .svc file methood
kuttikrishna...
Re: How to get SOAP Message From .svc file methood
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "MyTestService" in code, svc and config file together. public class MyTestService : IMyTestService { public int AddTheNumbers(int intA, int intB) { int intResult; string str = OperationContext.Current.RequestContext.RequestMessage.ToString(); MessageHeaders messageHeaders = OperationContext.Current.IncomingMessageHeaders; string headerIndex = messageHeaders.GetHeader("ClientID", "ns");
// result += headerIndex;
// Message response = Message.CreateMessage(request.Version, ReplyAction, result);
//return response;
ServiceManager objSM=new ServiceManager();
intResult=objSM.AddThenumbers(intA, intB);
return intResult;
}
}
IN CLIENT SIDE
protected void btnSum_Click(object sender, EventArgs e) { ServiceReference1.MyTestServiceClient objProxy = new ServiceReference1.MyTestServiceClient(); using (new OperationContextScope(objProxy.InnerChannel)) { MessageHeader msgHeader = MessageHeader.CreateHeader("ClientID", "ns", "1098", false); OperationContext.Current.OutgoingMessageHeaders.Add(msgHeader); txtResult.Text = objProxy.AddTheNumbers(Convert.ToInt32(txtFirstNumber.Text), Convert.ToInt32(txtSecondNumber.Text)).ToString(); } }
NOW ITS WORKING FINE https://forums.asp.net/t/1701908.aspx?How+to+get+SOAP+Message+From+svc+file+methood+