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:

line 85:         [system.web.services.protocols.soapdocumentmethodattribute("http://tempuri.org/nothelloworld", requestnamespace="http://tempuri.org/", responsenamespace="http://tempuri.org/", use=system.web.services.description.soapbindinguse.literal, parameterstyle=system.web.services.protocols.soapparameterstyle.wrapped)]  line 86:         public string nothelloworld() {  line 87:             object[] results = this.invoke("nothelloworld", new object[0]);  line 88:             return ((string)(results[0]));  line 89:         }

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:

[webexception: request failed http status 400: bad request.]     system.web.services.protocols.soaphttpclientprotocol.readresponse(soapclientmessage message, webresponse response, stream responsestream, boolean asynccall) +1335     system.web.services.protocols.soaphttpclientprotocol.invoke(string methodname, object[] parameters) +205     soapextensiontest.service.nothelloworld() in c:\windows\microsoft.net\framework\v2.0.50727\temporary asp.net files\aspwebsitetotestsoapextension\f927abdc\af7b19e5\app_webreferences.sfhwhqr-.0.cs:87     _default.page_load(object sender, eventargs e) in d:\myworkspace\dotnetexample\aspwebsitetotestsoapextension\default.aspx.cs:27     system.web.util.callihelper.eventargfunctioncaller(intptr fp, object o, object t, eventargs e) +13     system.web.util.callieventhandlerdelegateproxy.callback(object sender, eventargs e) +45     system.web.ui.control.onload(eventargs e) +80     system.web.ui.control.loadrecursive() +49     system.web.ui.page.processrequestmain(boolean includestagesbeforeasyncpoint

can 1 me resolve issue.

 

thanks



Archived Forums A-B  >  ASMX Web Services and XML Serialization



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'