c# - Unsupported Media Type with ASMX Web Service -



c# - Unsupported Media Type with ASMX Web Service -

i have been given old webservice .asmx work , although code works fine in debug mode (vs play debug on local host) when seek , write consumer app pass relevant soap request response cannot work.

in .net status 415 unsupported media type (never heard of before) - tech asked me media sending said text xml.

here code plus debug. tried writing asp classic version different errors depending on soap version.

the webservice on 1 server. trying consume local machine , server service prove can xml in debug mode.

webmethods in .amsx file e.g [webmethod] public string getname(string clienthash) { } running on localhost vs in debug mode works treat. copied files website in iis setup me called http://webservice.demo.co.uk config same in debug , release below has in next folder construction webservice.demo.co.uk/http.demo/app_data (empty) webservice.demo.co.uk/http.demo/bin -webservice.dll -webservice.pdb webservice.demo.co.uk/http.demo/properties -assemblyinfo webservice.demo.co.uk/http.demo/ -webservice.asmx -web.config config file contents <?xml version="1.0"?> <configuration> <configsections> <sectiongroup name="system.web.extensions" type="system.web.configuration.systemwebextensionssectiongroup, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"> <sectiongroup name="scripting" type="system.web.configuration.scriptingsectiongroup, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"> <sectiongroup name="webservices" type="system.web.configuration.scriptingwebservicessectiongroup, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"> </sectiongroup> </sectiongroup> </sectiongroup> </configsections> <connectionstrings> <add name="apidatabase" connectionstring="xxx" /> <add name="scotland" connectionstring="xxx" /> </connectionstrings> <appsettings> <add key="server" value="server1" /> <add key="demoserver" value="server12" /> <add key="serviceurl" value="http://webservice.demo.co.uk/" /> </appsettings> <system.web> <compilation debug="true" > <assemblies> <add assembly="system.core, version=3.5.0.0, culture=neutral, publickeytoken=b77a5c561934e089"/> <add assembly="system.data.datasetextensions, version=3.5.0.0, culture=neutral, publickeytoken=b77a5c561934e089"/> <add assembly="system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/> <add assembly="system.xml.linq, version=3.5.0.0, culture=neutral, publickeytoken=b77a5c561934e089"/> </assemblies> </compilation> <!-- <authentication> section enables configuration of security authentication mode used asp.net identify incoming user. --> <authentication mode="windows" /> <!-- <customerrors> section enables configuration of if/when unhandled error occurs during execution of request. specifically, enables developers configure html error pages displayed in place of error stack trace. <customerrors mode="remoteonly" defaultredirect="genericerrorpage.htm"> <error statuscode="403" redirect="noaccess.htm" /> <error statuscode="404" redirect="filenotfound.htm" /> </customerrors> --> <pages> <controls> <add tagprefix="asp" namespace="system.web.ui" assembly="system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/> <add tagprefix="asp" namespace="system.web.ui.webcontrols" assembly="system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/> </controls> </pages> <httphandlers> <remove verb="*" path="*.asmx"/> <add verb="*" path="*.asmx" validate="false" type="system.web.script.services.scripthandlerfactory, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/> <add verb="*" path="*_appservice.axd" validate="false" type="system.web.script.services.scripthandlerfactory, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/> <add verb="get,head" path="scriptresource.axd" type="system.web.handlers.scriptresourcehandler, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" validate="false"/> </httphandlers> <httpmodules> <add name="scriptmodule" type="system.web.handlers.scriptmodule, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/> </httpmodules> </system.web> <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" warninglevel="4" type="microsoft.csharp.csharpcodeprovider, system, version=2.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089"> <provideroption name="compilerversion" value="v3.5"/> <provideroption name="warnaserror" value="false"/> </compiler> </compilers> </system.codedom> <!-- system.webserver section required running asp.net ajax under net info services 7.0. not necessary previous version of iis. --> <system.webserver> <validation validateintegratedmodeconfiguration="false"/> <modules> <remove name="scriptmodule" /> <add name="scriptmodule" precondition="managedhandler" type="system.web.handlers.scriptmodule, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/> </modules> <handlers> <remove name="webservicehandlerfactory-integrated"/> <remove name="scripthandlerfactory" /> <remove name="scripthandlerfactoryappservices" /> <remove name="scriptresource" /> <add name="scripthandlerfactory" verb="*" path="*.asmx" precondition="integratedmode" type="system.web.script.services.scripthandlerfactory, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/> <add name="scripthandlerfactoryappservices" verb="*" path="*_appservice.axd" precondition="integratedmode" type="system.web.script.services.scripthandlerfactory, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/> <add name="scriptresource" precondition="integratedmode" verb="get,head" path="scriptresource.axd" type="system.web.handlers.scriptresourcehandler, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" /> </handlers> </system.webserver> <runtime> <assemblybinding appliesto="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentassembly> <assemblyidentity name="system.web.extensions" publickeytoken="31bf3856ad364e35"/> <bindingredirect oldversion="1.0.0.0-1.1.0.0" newversion="3.5.0.0"/> </dependentassembly> <dependentassembly> <assemblyidentity name="system.web.extensions.design" publickeytoken="31bf3856ad364e35"/> <bindingredirect oldversion="1.0.0.0-1.1.0.0" newversion="3.5.0.0"/> </dependentassembly> </assemblybinding> </runtime> </configuration> examples when running debug soap 1.1 next sample soap 1.1 request , response. placeholders shown need replaced actual values. post /webservice.asmx http/1.1 host: localhost content-type: text/xml; charset=utf-8 content-length: length soapaction: "http://webservice.demo/getname" <?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:body> <getname xmlns="http://webservice.demo/"> <clienthash>string</clienthash> </getname> </soap:body> </soap:envelope> http/1.1 200 ok content-type: text/xml; charset=utf-8 content-length: length <?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:body> <getnameresponse xmlns="http://webservice.demo/"> <getnameresult>string</getnameresult> </getnameresponse> </soap:body> </soap:envelope> soap 1.2 next sample soap 1.2 request , response. placeholders shown need replaced actual values. post /webservice.asmx http/1.1 host: localhost content-type: application/soap+xml; charset=utf-8 content-length: length <?xml version="1.0" encoding="utf-8"?> <soap12:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:body> <getname xmlns="http://webservice.demo/"> <clienthash>string</clienthash> </getname> </soap12:body> </soap12:envelope> http/1.1 200 ok content-type: application/soap+xml; charset=utf-8 content-length: length <?xml version="1.0" encoding="utf-8"?> <soap12:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:body> <getnameresponse xmlns="http://webservice.demo/"> <getnameresult>string</getnameresult> </getnameresponse> </soap12:body> </soap12:envelope> console project app debug trying run c:\users\rreid>"c:\users\me\documents\visual studio 2010\projects\websrvice\testwebservice\bin\debug\testwebservice.exe" start 07/10/2014 16:33:31 send xml == <?xml version="1.0" encoding="utf-8"?> <soap12:envelope xmlns:xi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001xmlschema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:body> <getname xmlns="http://webservice.demo/"> <clienthash>6d104928-7633-4998-90c5-c01abd4010b</clienthash> </getname> </soap12:body> </soap12:envelope> in httprequest post - http://webservice.demo.co.uk/webservice.asmxop=getname <?xml version="1.0" encoding="utf-8"?> <soap12:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:body> <getame xmlns="http://webservice.demo/"> <clienthash>6d104928-7633-4998-90c5-c01abd4e010</clienthash> </getname> </soap12:body> </soap12:envelope> useragent - robsbot end of init in makehttprequest in accessurl create post request http://webservice.demo.co.uk/webservice.asmx?op=getname create post request http://webservice.demo.co.uk/webservice.asm?op=getname add together headers create request robsbot convert post info stream = <?xml version="1.0" encoding="utf-8"?> <soap12:evelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://ww.w3.org/2001/xmlschema" mlns:soap12="http://www.w3.org/2003/05/soap-envelope><soap12:body> <getname xmlns="http://webservice.demo/"> <clienthash>6d104928-7633-498-90c5-c01abd4e010b</clienthash> </getname> </soap12:body> </soap12:envelope> **webexeption remote server returned error: (415) unsupported media type. status = 415 - unsupported media type error = remote server returned error: (415) unsupported media type. error = unknown error statuscode 415 - tries = 1** error unknown error stop 07/10/2014 16:33:34 http status 415 error unsupported media type? need add together headers request or response or format xml differently? tried running both soap 1.1 , 1.2 asp classic got 2 different errors server unable process request. ---> root element missing. , server did not recognize value of http header soapaction: /getname. doing wrong? know .asmx old have taken on project. need consumer app can take works vs on localhost pc server or server server. why many errors , unsupported media type error 415? how can prepare , cant resolve http status code 415 reading there 1000000 different possibilities.

c# xml web-services soap asmx

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -