Setting a asp.net 2.0 webmethod as a GET method - web-services

But default you have to issue an HTTP POST to any web method in an asp.net 2.0 web service. How do u call a web method with HTTP GET alone. In some cases I'd also want to pass arguments to an HTTP GET method. Is this possible in the context of web services?

The accepted answer does not answer the question perfectly since you need the ASP.NET AJAX extensions for the suggested decoration to work in 2.0.
The easiest alternative to support both GET and POST for a 2.0 webservice is to setup these in web.config:
<system.web>
<webServices>
<protocols>
<add name="HttpPost" />
<add name="HttpGet" />
</protocols>
</webServices>
</system.web>

[ScriptMethod(UseHttpGet = true)]
You can use the above to make the webmethod support GET
http://www.asp.net/ajax/tutorials/understanding-asp-net-ajax-web-services

Related

Apache ServiceMix! Request-Replay Web Service message

Hello!
I'm trying to learn some Apache Camel and Apache CXF and of course I've ran into some problems.
What I'm trying to do:
Send timed SOAP messages from ESB to some web service, wait for the reponse from the web service and process it. I'm using Apache ServiceMix!.
What I've done:
Implemented a WSDL file with two operations PingOutput (what I'm sending) and PingInput (what I want to receive from the WS).
Implemented a CXF Endpoint (http://127.0.0.1:8090/ping_ws is a WS mocked with SoapUI):
<cxf:cxfEndpoint address="http://127.0.0.1:8090/ping_ws"
id="Ping_Mocked_WS" wsdlURL="ping.wsdl">
<cxf:properties>
<entry key="dataFormat" value="PAYLOAD" />
</cxf:properties>
</cxf:cxfEndpoint>
Implemented a Camel route:
<camelContext xmlns="http://camel.apache.org/schema/spring" streamCache="true">
<route id="ping-ws">
<from uri="timer://ping_timer?fixedRate=true&period=10000"/>
<bean ref="PingBean" method="createPingRequest" />
<to uri="cxf:bean:Ping_Mocked_WS"/>
<bean ref="PingBean" method="processPingResponse" />
</route>
</camelContext>
What I do not understand:
Why the <bean ref="PingBean" method="processPingResponse" /> gets the correct response from SoapUI (the PingOutput operation defined in WSDL)?
Is this the correct way to achieve my goal? And by this way I mean with one single route?
The codes work correctly, I might have some typos here, please do not mind them.
Thanks!
Ad 1)
Likely because the type defined in the method signature of the processPingResponse method. Camel uses bean parameter binding, and based on the type, it uses its type converter to convert to the given type.
And as the payload is a SOAP response in XML it can use JAXB to convert from XML to the type from the method signature.
To do so it uses camel-jaxb which ServiceMix comes with out of the box.
Ad2)
The route works. What it is you want to do differently?

Webservice .Net 4.0 publishing problems in IIS7

I cant get my Webservice published, it should be simple:
I create the app in the IIS,
place it as a 4.0 Classic .Net
I publish it from .Net Solution within VS2012 Right click and publish
on the Webservice project.
The files are placed and it should show by itself on the browser on the URL of the server specified.
But I stumbled upon the following problems:
HTTP Error 404.17 - Not Found
The requested content appears to be script and will not be served by the static file handler.
So I've looked for It and found this two options:
Option 1:
http://www.banmanpro.com/support2/Requested_Content_Appears_to_be_Script.asp
This one says I should go to Integrated, instead of Classic App Pool. but it's like if I changed a problem for another because now it says:
HTTP Error 500.21 - Internal Server Error
Handler "WebServiceHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list
When I go to the web config see what is this error talking about I see no handler tag!
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings />
<connectionStrings />
<system.web>
<compilation targetFramework="4.0" />
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows" />
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm"/>
<error statusCode="404" redirect="FileNotFound.htm"/>
</customErrors>
-->
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
</system.web>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
</configuration>
Should I add one? If so, how?
Option 2:
Script not served by static file handler on IIS7.5
Basically it says I shoud do a aspnet_regiis -i, but when I try
going to %windir%\Microsoft.NET\Framework\v4.0.30319
Even when the folder exists, There is no aspnet_regiis!!
I've only found the aspnet_regiis on the 2.0 Fwk =(
Is that normal?
The handler tag wasn't the answer, however, both options drove me to look for the missing aspnet_regiis of fwk 4.
There was no aspnet_regiis because the full fwk 4.0 wasn't actually installed on a first place.
I had installed on the server the Framework 4 Client Profile and the debugger, which isn't the full version. From now on, whenever I think I have fwk 4 installed, I'll check twice.
After installing it, on Framework 4.0 Classic Pipeline Mode (instead of Integrated) made it work just fine.
But Attention!
After installing the framework, IIS will change the default pipeline to 4.0, that means, if you had ongoing a web(site/service) on 2.0 it will automatically stop working. (It happened to me)

Spring web services validation

I've two kinds of webservices:
webservices that need the request to be validated
others that must not be validated by Spring.
Is this possible in Spring?
I know about ValidatingInterceptor, but can we have two of these?
The reason for not validating one type of web service is that the request is not defined: what's sent in the request, depends on many things.
I am using Spring 3.0, with schema XSD's for my webservices.
Any suggestions?
Adi
You can use two payloadroot within a interceptor for that purpose.
All you need to do is to set validateRequest/validateResponse as true or false as required.
Here is a sample:
<sws:interceptors>
<sws:payloadRoot namespaceUri="uri1">
<bean id="validator1forUri1"
class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor"
p:schema="classpath:/WEB-INF/xsds/tovalidate.xsd" p:validateRequest="true"
p:validateResponse="true" />
</sws:payloadRoot>
<sws:payloadRoot namespaceUri="uri2">
<bean id="validator2forUri2"
class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor"
p:schema="classpath:/WEB-INF/xsds/nottovalidate.xsd"
p:validateRequest="false" p:validateResponse="false" />
</sws:payloadRoot>
</sws:interceptors>

How to get raw data from Web Service Request?

I want to check raw data string (raw xml) received by my web service methods (for logging and debugging purposes).
I saw recommendations: to handle 'BeginRequest' event in HttpApplication. But I don't see which field of 'Request' object contains this POST data?
Related question: Getting RAW Soap Data from a Web Reference Client running in ASP.net
- Have you seen this answer using tracing? or this one using a SoapExtension
I made following changes in web.cofig
to get SOAP(Request/Response)
Envelope. It makes trace.log file
where all the required information are
present
<system.diagnostics>
<trace autoflush="true"/>
<sources>
<source name="System.Net" maxdatasize="1024">
<listeners>
<add name="TraceFile"/>
</listeners>
</source>
<source name="System.Net.Sockets" maxdatasize="1024">
<listeners>
<add name="TraceFile"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add name="TraceFile" type="System.Diagnostics.TextWriterTraceListener" initializeData="trace.log"/>
</sharedListeners>
<switches>
<add name="System.Net" value="Verbose"/>
<add name="System.Net.Sockets" value="Verbose"/>
</switches>
It would not make sense to keep all the request post data in the request object since it could contain uploaded file and be very big.
I have two solutions for you:
1) Use Fiddler on the server and browse locally the website (using server name and not localhost since Fiddler cannot show localhost request/responses)
2) Use System.Net tracing: http://support.microsoft.com/kb/947285
You can also use WireShark to look at the packets but this will not keep the request response context.

How to report progress of a web service on windows mobile client?

I have tried to implement progress reporting using a soap extension as described at the following links:
stackoverflow
codeproject
However, my "ProgressUpdate" method is not being called, and I believe that is because I haven't got an app.config file in my Windows Mobile project to tell the web service calls to be processed by the SOAP Extension. How can do it in Windows Mobile? This is the sample config file used in the article:
<?xmlversion="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<webServices>
<soapExtensionTypes> <add
type="SoapExtensionLib.ProgressExtension, SoapExtensionLib"
priority="1" group="High" />
</soapExtensionTypes>
</webServices>
</system.web>
</configuration>
I figured out how to do this by adding a custom attribute to the method inside the generated proxy class. The custom attribute is derived from SoapExtensionAttribute.
I got the information at MSDN
Problem now is that I have to remember to add the attribute back in if I refresh the web service reference..............