The request failed with HTTP status 400: Bad Request.
hi,
i trying use soapextension in web services processing of soap request , response befor serlize , deserilazation. facing challenges . first let see did implement soapextension.
1) have created class customsoapextension : soapextension . below code
namespace soapextensionclasslibrary
{
public class customsoapextension : soapextension
{
private stream oldstream;
private stream newstream;
public override object getinitializer(type servicetype)
{
return null;// throw new exception("the method or operation not implemented.");
}
public override object getinitializer(logicalmethodinfo methodinfo, soapextensionattribute attribute)
{
testsoapextensionattribute lta = (testsoapextensionattribute)attribute;
// error traps removed clarity
return new string[] { lta.paramname1, lta.paramname2 };
}
public override void initialize(object initializer)
{
//return null;//throw new exception("the method or operation not implemented.");
}
public override system.io.stream chainstream(system.io.stream stream)
{
newstream = stream;
stream.seek(0, seekorigin.begin);
writetolog("in chain stream" + "test", stream);
stream.seek(0, seekorigin.begin);
oldstream = new memorystream();
return oldstream;
}
public override void processmessage(soapmessage message)
{
//throw new exception("the method or operation not implemented.");
string messagetype;
if (message.gettype() == typeof(soapservermessage))
messagetype = "server message";
else
messagetype = "clent meassage";
stream stream = message.stream;
/*
switch(message.stage)
{
case soapmessagestage.beforedeserialize:
stream.seek(0, seekorigin.begin);
writetolog("before deserialize" + messagetype, stream);
stream.seek(0, seekorigin.begin);
break;
case soapmessagestage.beforeserialize:
stream.seek(0, seekorigin.begin);
writetolog("before serialize" + messagetype, stream);
stream.seek(0, seekorigin.begin);
break;
case soapmessagestage.afterdeserialize:
stream.seek(0, seekorigin.begin);
writetolog("afterdeserialize" + messagetype, stream);
stream.seek(0, seekorigin.begin);
break;
case soapmessagestage.afterserialize:
stream.seek(0, seekorigin.begin);
writetolog("afterserialize" + messagetype, stream);
stream.seek(0, seekorigin.begin);
break;
}*/
}
private void writetolog(string strtitle,stream stream)
{
streamreader sr=new streamreader(stream);
streamwriter sw=new streamwriter(@"d:\myworkspace\customsoapextensionlog.txt",true);
sw.writeline(strtitle + sr.readtoend());
sr.close();
sw.close();
sw=null;
}
}
[attributeusage(attributetargets.method)]
public class testsoapextensionattribute : soapextensionattribute
{
public string paramname1;
public string paramname2;
public override int priority
{
get
{
//throw new exception("the method or operation not implemented.");
return 1;
}
set
{
//throw new exception("the method or operation not implemented.");
}
}
public override type extensiontype
{
get {
//throw new exception("the method or operation not implemented.");
return typeof(customsoapextension);
}
}
public testsoapextensionattribute(string param1, string param2)
{
this.paramname1 = param1;
this.paramname2 = param2;
}
}
}
2) have created web service class method helloworld
[webmethod,soapextensionclasslibrary.testsoapextensionattribute("name1","name2")]
public void helloworld() {
//return "hello world java";
}
3) created asp.net file use call helloworld method. when executing asp.net application , getting error message
the request failed http status 400: bad request.
description: an unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code.
exception details: system.net.webexception: request failed http status 400: bad request.
source error:
|
source file: c:\windows\microsoft.net\framework\v2.0.50727\temporary asp.net files\aspwebsitetotestsoapextension\f927abdc\af7b19e5\app_webreferences.sfhwhqr-.0.cs line: 87
stack trace:
|
can 1 me resolve issue.
thanks
http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soapextension.aspx
Archived Forums A-B > ASMX Web Services and XML Serialization
Comments
Post a Comment