|
I am working on soapextension that compresses soap message.
I am stuck at only one stage now. When I get response from webservice....on client at -BeforeDeserialize stage when I try to copy original or old stream to temp stream so that I can
de compress it, I get 'Stream dose not support seek operation' error.
Has any one come across smilar issue ...that while altering stream you could not capture it properly when client recieves it from server
debugging
This code will create new file for input and output each stage. You can see that till that point message is getting compressed and de compressed properly. Sort file by Date created
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.IO;
using System.IO.Compression;
using System.Xml;
using System.Threading;
namespace GZIPSoapExtension
{
public class GZIPSoapExtension : SoapExtension
{
protected Stream OriginalStream = null;
protected Stream NewStream = null;
protected String Mode = null;
public override object GetInitializer(Type WebServiceType)
{
return "C:\\" + WebServiceType.FullName + ".log";
}
public override object GetInitializer(LogicalMethodInfo methodInfo, SoapExtensionAttribute attribute)
{
return null;
}
public override void Initialize(object initializer)
{
}
public override Stream ChainStream(Stream stream)
{
OriginalStream = stream;
NewStream = new MemoryStream();
return NewStream;
}
public override void ProcessMessage(SoapMessage message)
{
Mode = "";
switch (message.Stage)
{
case SoapMessageStage.BeforeSerialize:
Mode = "BeforeSerialize";
break;
case SoapMessageStage.AfterSerialize:
Mode = "AfterSerialize";
AfterSerializeHandler(message);
break;
case SoapMessageStage.BeforeDeserialize:
Mode = "BeforeDeserialize";
BeforeDeserializeHandler(message);
break;
case SoapMessageStage.AfterDeserialize:
Mode = "AfterDeserialize";
break;
}
}
public void BeforeDeserializeHandler(SoapMessage message)
{
WriteToLog("BeforeDeserializeHandler -- BeforeDecompress", message, OriginalStream);
Stream ms = new MemoryStream ();
Copy(OriginalStream, ms);
ms.Position = 0;
ms = DeCompressData(ms);
ms.Position = 0;
NewStream.Position = 0;
Copy(ms, NewStream);
ms.Position = 0;
NewStream.Position = 0;
WriteToLog("BeforeDeserializeHandler -- After Decompress", message, NewStream);
ms.Position = 0;
NewStream.Position = 0;
}
public void AfterSerializeHandler(SoapMessage message)
{
WriteToLog("AfterSerializeHandler -- before Compress" ,message, NewStream);
MemoryStream ms = new MemoryStream();
NewStream.Position = 0;
Copy(NewStream, ms);
NewStream.Position = 0;
ms.Position = 0;
ms= CompressData(ms);
ms.Position = 0;
NewStream.Position = 0;
Copy(ms, OriginalStream);
ms.Position = 0;
WriteToLog("AfterSerializeHandler -- After Compress", message, ms);
}
protected void Copy(Stream from, Stream to)
{
from.Position = 0;
int bytesRead;
byte[] buffer = new byte[2];
BinaryReader reader = new BinaryReader(from);
BinaryWriter writer = new BinaryWriter(to);
do
{
bytesRead = reader.Read(buffer, 0, buffer.Length);
writer.Write(buffer, 0, bytesRead);
} while (bytesRead > 0);
writer.Flush();
}
public MemoryStream CompressData(MemoryStream source)
{
if (source == null) return null;
MemoryStream ms = new MemoryStream();
GZipStream compressedzipStream = null;
try
{
byte[] buffer = new byte[source.Length];
source.Position = 0;
source.Read(buffer, 0, buffer.Length);
compressedzipStream = new GZipStream(ms, CompressionMode.Compress, true);
compressedzipStream.Write(buffer, 0, buffer.Length);
}
finally
{
compressedzipStream.Close();
}
return ms;
}
public MemoryStream DeCompressData(Stream s)
{
if (s == null) return null;
s.Position = 0;
GZipStream gs = new GZipStream(s, CompressionMode.Decompress);
BinaryReader reader = new BinaryReader(gs);
MemoryStream result = new MemoryStream();
BinaryWriter writer = new BinaryWriter(result);
int bytesRead;
byte[] buffer = new byte[2];
try
{
do
{
bytesRead = reader.Read(buffer, 0, buffer.Length);
writer.Write(buffer, 0, bytesRead);
} while (bytesRead > 0);
writer.Flush();
result.Position = 0;
}
finally
{
}
return result;
}
public void WriteToLog(String Source ,SoapMessage message, Stream s)
{
Thread.Sleep(1000);
int bytesRead;
String MsgType = null;
byte[] buffer = new byte[2];
if (message.GetType() == typeof(SoapServerMessage)) MsgType = "ServerMessage";
if (message.GetType() == typeof(SoapClientMessage)) MsgType = "ClientMessage";
//It logs message in new file. Just to make it easy to debug compressed message.
FileStream fs = new FileStream("C:\\" + MsgType + "-" + Source + "-" + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + ".txt", FileMode.Append, FileAccess.Write);
try
{
BinaryReader reader = new BinaryReader(s);
BinaryWriter writer = new BinaryWriter(fs);
do
{
bytesRead = reader.Read(buffer, 0, buffer.Length);
writer.Write(buffer, 0, bytesRead);
} while (bytesRead > 0);
writer.Flush();
}
finally
{
//if (swr != null) swr.Close();
if (fs != null) fs.Close();
}
}
}
[AttributeUsage(AttributeTargets.Method)]
public class GZIPSoapExtensionAttribute : SoapExtensionAttribute
{
private int _Priority = 1;
public override int Priority
{
get
{
return _Priority;
}
set
{
_Priority = value;
}
}
public override Type ExtensionType
{
get { return typeof(GZIPSoapExtension); }
}
}
}
kyus
|
|
|
|
|
I am getting a following error when i connect to a site.
"HTTP 407 Proxy Authentication Required - The ISA Server requires authorization to fulfill the request."
Its due to server authentication. Is it possibel to overcome this through code?
|
|
|
|
|
set the
obj.proxy = null;
|
|
|
|
|
im trying to develop a web project using vs2008 team edition ... other people on the project have a "new website" template for "ajax enabled web site" type thingy but i do not ... is there anything i need to do to get that option? (sacrifice a chicken, dance naked in the rain, go to church, etc etc)
thnx
"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"
|
|
|
|
|
Probably install the ASP.NET AJAX extensions.
However, you quite plainly do not need VS2008 to create ANYTHING on the project level to be able to use AJAX, you just need a project that imports that dll if you want to use the Microsoft AJAX enabled controls.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
i just figured that out before your email arrived ... thnx christian
"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"
|
|
|
|
|
*grin*
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
l a u r e n wrote: m trying to develop a web project using vs2008 team edition
I thought you were an anti-microsofty linux type?
led mike
|
|
|
|
|
not anti-microsoft ... i grew up programming x86 and dos / windows and still do (well not dos so much anymore ) ... i just write and teach a lot of open source stuff these days and i do run linux most of the time because i prefer the ethos of it all ... right now i have a project in europe that requires asp.net so im using the tools for that job
"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"
|
|
|
|
|
l a u r e n wrote: right now i have a project in europe that requires asp.net so im using the tools for that job
Ah, that clears up a lot. Good luck on the project and have a great weekend. It's a 3 day holiday for use here in the US.
led mike
|
|
|
|
|
im in san francisco so its a 3 day holiday for me too (not that i get holidays much as a self employed worker) ... i just have a job from someone in europe
"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"
|
|
|
|
|
hi,
i am beginner to webservices.please help me on solving my problem.i have one webservice "clusterws" and i created one proxy class i want to test this proxy class using one webapplication to call the methods in my w
ebservice
please tell me the diferent ways to test proxy class with complete code.
thank u
madhavi.kona
|
|
|
|
|
HI, all
Hi If you feel its very simple plz let me know how its gonna work...
since its not a programming one, I am posting here...
I am preparing an appliction for which, I want to know hw the authentication(Basic and Access )will go under our WINDOW's authentication.,
and I want to test/know how HTTP Pipelining works in ASP.Net,
I have to prepare testcase document on this, Please help me,
Thanks,
Pashi
|
|
|
|
|
Hi all,
I need a suggestion to solve the below problem.
intXOffset = window.event.offsetX;
intYOffset = window.event.offsetY;
the above code works good in IE but not in any other browsers
how to write a browser independent javascript for this. Also there is a problem with this code. The function containing this code is called onLoad of the body and onclick of a image.
Also any one suggest me a URL from where i can learn browser independent javascript.
Thanks in advance
Know is Drop, Unknown is Ocean
|
|
|
|
|
http://www.unix.com.ua/orelly/web/jscript/ch18_01.html
|
|
|
|
|
I want to know that what will be the server in case of server side javascript.
I know the code for that but my code is not running on IIS server.
If server is tomcat than what will be the structure of that folder, because in tomcat we must need web_inf .
|
|
|
|
|
Server side javascript ???
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
ummmmm javascript is client side ... runs in the browser
you mean server side java - servlets?
"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"
|
|
|
|
|
Classic ASP could do server-side Javascript. You don't want to use Classic ASP though. Trust me.
You could use Rhino[^] to run JS code on a server JVM, spitting out pages that way. Which sounds cool, but i've no experience with it and not too many other people do either, so prepare yourself for a lot of work getting things up and running.
Citizen 20.1.01 'The question is,' said Humpty Dumpty, 'which is to be master - that's all.'
|
|
|
|
|
Greetings to all,
I have just recently used the ajax autocomplete and after an hour or so, I finally go it to work. However, I noticed that only the 1st char of the input text is case sensitive. How do I set the autocompete control in such a way that every char that the user types in is case sensitive.
E.G.
Presently, this is what happens:
DB table values = hello, Hello, hEllo, hELLO
User input = hEllo
autocomplete value = hello, Hello, hEllo, hELLO
I want it to be:
User input = hEllo
autocomplete value = hEllo, hELLO
|
|
|
|
|
|
Hi Everybody,
How can i disable 'Save Background as' option when right clicking my mouse?
|
|
|
|
|
in the image wrie like this
Thanks
Laddie
Kindly rate if the answer was helpful
modified on Wednesday, May 21, 2008 10:26 AM
|
|
|
|
|
venkat86_ece wrote: How can i disable 'Save Background as' option when right clicking my mouse?
You don't. There are hacks that will work some of the time in some browsers, but they'll eventually go away because folks abuse them for things like disabling context menus instead of anything that actually helps the user. If someone is asking you to do this, then go back and tell them that it's a terrible idea and won't work.
Citizen 20.1.01 'The question is,' said Humpty Dumpty, 'which is to be master - that's all.'
|
|
|
|
|
I have a problem with ReorderList control. It does not work correctly when attribute DataSourceId is set to XmlDataSource... When I moving items of this control some strange message appears:
"Reorder failed. It is not a DataSource and does not implement IList."
I wonder to know, how must I fix this problem.
I heard that it happens only if XmlDataSource is used as DataSourceID in ReorderList Control, but I must use this option...
Is there any solution of this problem?
here is the print-screen of the message which appears:
http://krokodajl.drivehq.com/xmlreorder.jpg[^]
Code for the ReorderList Control:
<cc1:ReorderList runat="server" ID="rol1" DataSourceID="XmlDataSource1"
PostBackOnReorder="false" AllowReorder="true" ItemInsertLocation="Beginning">
<ItemTemplate>
<%#XPath("id") %>
</ItemTemplate>
<ReorderTemplate>
<asp:Panel ID="reorderPanel" runat="server" CssClass="reorderCue"></asp:Panel>
</ReorderTemplate>
<DragHandleTemplate>
<div class="dragHandle"></div>
</DragHandleTemplate>
</cc1:ReorderList>
Code for the XmlDataSource Control:
<asp:xmldatasource id="XmlDataSource1" runat="server" DataFile="~/XMLFile.xml" XPath="source/dane" />
modified on Wednesday, May 21, 2008 8:42 AM
|
|
|
|