public Stream Post(Stream istrm)
{
MemoryStream mstrm = new MemoryStream();
int bytesRead = 0;
byte[] buffer = new byte[4096];
do
{
bytesRead = istrm.Read(buffer, 0, buffer.Length);
mstrm.Write(buffer, 0, bytesRead);
}
while (bytesRead != 0);
mstrm.Position = 0;
Dictionary<string, string> options = Parse(WebOperationContext.Current.IncomingRequest.ContentType);
string securityPolicyUri = WebOperationContext.Current.IncomingRequest.Headers["OPCUA-SecurityPolicy"];
StringBuilder contentType2 = new StringBuilder();
string action = null;
if (options[String.Empty] == "application/octet-stream")
{
contentType2.Append("application/octet-stream");
}
else if (options[String.Empty] == "application/soap+xml")
{
action = options["action"];
if (action == null)
{
throw new WebException("SOAP Action not specified.");
}
action = action.Substring(Namespaces.OpcUaWsdl.Length+1);
contentType2.Append("application/soap+xml; charset=\"utf-8\"; action=\"");
contentType2.Append(Namespaces.OpcUaWsdl);
contentType2.Append("/");
contentType2.Append(action);
contentType2.Append("Response");
}
else
{
throw new WebException("ContentType not supported.");
}
WebOperationContext.Current.OutgoingResponse.ContentType = contentType2.ToString();
IAsyncResult result = m_listener.BeginProcessRequest(mstrm, action, securityPolicyUri, null);
Stream ostrm = m_listener.EndProcessRequest(result);
return ostrm;
}