public virtual TypeCheckResponse TypeCheckRequest(TypeCheckRequest req) { // Create request header String action; action = "http://schemas.example.org/SimpleService/TypeCheckRequest"; WsWsaHeader header; header = new WsWsaHeader(action, null, ServiceEndpoint, null, EndpointAddress, null); // Create request serializer TypeCheckRequestDataContractSerializer reqDcs; reqDcs = new TypeCheckRequestDataContractSerializer("TypeCheckRequest", "http://schemas.example.org/SimpleService"); // Build soap request message byte[] soapBuffer = SoapMessageBuilder.BuildSoapMessage(header, reqDcs, req); // Send service request DpwsHttpClient httpClient; httpClient = new DpwsHttpClient(); DpwsSoapResponse response; response = httpClient.SendRequest(soapBuffer, ServiceEndpoint, false, false); // Process response TypeCheckResponseDataContractSerializer respDcs; respDcs = new TypeCheckResponseDataContractSerializer("TypeCheckResponse", "http://schemas.example.org/SimpleService"); TypeCheckResponse resp; resp = ((TypeCheckResponse)(respDcs.ReadObject(response.Reader))); return(resp); }
public virtual void OneWay(OneWay req) { // Create request header String action; action = "http://schemas.example.org/SimpleService/OneWay"; WsWsaHeader header; header = new WsWsaHeader(action, null, ServiceEndpoint, null, EndpointAddress, null); // Create request serializer OneWayDataContractSerializer reqDcs; reqDcs = new OneWayDataContractSerializer("OneWay", "http://schemas.example.org/SimpleService"); // Build soap request message byte[] soapBuffer = SoapMessageBuilder.BuildSoapMessage(header, reqDcs, req); // Send service request DpwsHttpClient httpClient; httpClient = new DpwsHttpClient(); DpwsSoapResponse response; response = httpClient.SendRequest(soapBuffer, ServiceEndpoint, true, false); }
public int MyTwoWayOperation(int a, int b) { // Create HttpClient and send request Debug.Print("Sending Request:"); byte[] request = BuildMyTwoWayRequest(a, b); Debug.Print(new string(Encoding.UTF8.GetChars(request))); DpwsHttpClient httpClient = new DpwsHttpClient(); DpwsSoapResponse response = httpClient.SendRequest(request, // soap message this.serviceTransportAddress, false, //is one way? false // is chunked? ); if (response == null) { throw new InvalidOperationException("Two-way response was null."); } try { return(ParseTwoWayResponse(response.Reader)); } finally { response.Reader.Close(); } }
public void MyOneWayOperation(int a) { // Create HttpClient and send request Debug.Print("Sending Request:"); byte[] request = BuildMyOneWayRequest(a); Debug.Print(new string(Encoding.UTF8.GetChars(request))); DpwsHttpClient httpClient = new DpwsHttpClient(); httpClient.SendRequest(request, // soap message this.serviceTransportAddress, true, //is one-way? false // is chunked? ); }
public int MyTwoWayOperation(int a, int b) { // Create HttpClient and send request Debug.Print("Sending Request:"); byte[] request = BuildMyTwoWayRequest(a, b); Debug.Print(new string(Encoding.UTF8.GetChars(request))); DpwsHttpClient httpClient = new DpwsHttpClient(); DpwsSoapResponse response = httpClient.SendRequest(request, // soap message this.serviceTransportAddress, false, //is one way? false // is chunked? ); if (response == null) { throw new InvalidOperationException("Two-way response was null."); } //if (response.Header.Action == "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault") // throw new Exception(); CheckFaultResponse(response); return(ParseTwoWayResponse(response.Reader)); }