How to find internally calling service URLs from first service in C# - c#

I would like to know how to find the urls of internally referred services when hitting the first service.. is there any way? in fiddler I couldn't find.
I have a webservice customer.asmx contains method A(). I know only customer.asmx service complete url, with it's URL I am testing the method A in wcftestclient.
I get to know through code method A is calling reports.asmx and again resports.asmx is calling another service catalogue.asmx.
I am actually testing the test environment service, so I am not sure of the reports.asmx to which it is pointing I want to find out
Is there any way to know the complete urls of reports and catalogue services while testing my initial customer.asmx.

Related

My web service operation call only opens test page in IIS - I am not sure how to call the operation to return my xml

I am new to web services.
I have built a web service in C# that consumes a third party service and then returns the XML response from that call in a web method.
When I test this in IIS on the local web server it works perfectly.
However when I try to call or invoke the service via the URL I use on the test page I can't return a response.
If I use a GET I simply get the test page loading and the message I can't use this test page outside of the local server.
In short, I simply want to know how to call the web method externally and mimic the INVOKE button being pressed so I get the response passed back.
This is probably really simple but I can't get my head around it.
In addition if I use Postman to try and call the URL:
WebService.asmx?op=GetSalesOrders
I get the error message detailed below which is a step forward but I am still unsure about how to package up a call to this service
You call the service by making a POST request with a properly formated SOAP message to this URL:
<path>/WebService.asmx
You get the WSDL of the web service by making a GET request to this URL:
<path>/WebService.asmx?wsdl
You can use that WSDL to build a client or test the service with something like SoapUI. See this and this for more details.
That invocation page or URLs with parameters like this:
<path>/WebService.asmx?op=GetSalesOrders
are just provided for convenience to allow you to poke at the service and make sure the service is running. They should not be used in "real" calls.

How can a WCF Service obtain Query Parameters?

I'm working on an Azure service for a Windows Phone app. I need the Azure Service to access the users' OneDrive. Following this article, my scenario should be:
The user sign in to Windows Live on the WP app.
The Live web service sends the authorization code to a redirect URI that I defined, with the code appended as a query parameter named code, as:
http://www.example.com/callback.php?code=2bd12503-7e88-bfe7-c5c7-82274a740ff
I get the authorization code and access the users' data
After investigating a lot in Service, I still can't find a way to capture the query parameter in my web service. As I am new to this area, I don't know where to focus on. I'll be really appreciated if you can give my an advise or answer my following questions:
Can I access the service just using the url with parameter in a browser? How can I see if the service is working properly?
An article mentioned using WCF [Web Get] attribute to get Query Parameters, but I still don't know how to implement both the IService1.cs and Service1.cs file, could you give me a sample about how to access the value of Query Parameter?
Thanks!
I'm not sure if i understand your problem properly but if you want your RESTfull WCF service to be the callback receiver for the request code, your Service must be hosted with a WebHttpBinding and a ServiceContract similar to this one.
[ServiceContract]
public interface IService
{
[WebGet(UriTemplate = "callback?code={requestCode}")]
void OAuthCallback(string requestCode);
}
So if the base address of your Service is "http://service.mydomain.com/MyService.svc" the OAuthCallback Method will be called when a http GET request to "http://service.mydomain.com/MyService.svc/callback?code=RequestCode" is made.

Not sure how to construct a URL to call a web service method

I have just written my first SOAP web service. It's fairly simple. It just runs Powershell scripts or functions in a couple different manners. My problem is that I'm not sure how to construct a URL to call my methods. I'm sure it's just due to my inexperience with web services.
The method definition is RunPowershellScriptWithArgsExportJson(string scriptPath, string[] scriptArgs). The scriptPath is a local path like C:\Scripts\Testing.ps1. scriptArgs could potentially be anything.
I've verified that I can see the xml response in a browser by entering the path to the asmx. It was similar to http://PCName.com/PsWebService/ServiceName.asmx. (We're only using this service on our internal network so I'm using the computer name instead of a domain name in the URL)
I can also invoke the methods from remote computers with Powershell and its New-WebServiceProxy cmdlet, but that doesn't require a URL that includes method calls. So the web service appears to work. I'm just not sure how to call it in a URL which is ultimately what I need.
Could someone provide me with an example of a URL that would work to call my RunPowershellScriptWithArgsExportJson method correctly? I've tried several things and also read a few blogs and tech articles, but so far I'm just getting random URL exceptions on everything I try.

Global variables in WCF REST services

My applciation works as follows
[user]----username/password/domain----->[WCF service]
then i access the domain server to see to which actual DB the user is associated,
after getting that, i validate the user in his actual DB(DB is per domain)
the problem is that i need a place to store the domain name for the following requests against the db.
for example,if the users calls a WCF service operation:
Test()
first the validation procedure is called, (WCF UserNamePasswordValidator) which validates the user password(which is sent as part of the header for REST or as part of the SOAP), and the next function to be called is the Test, but by then i cant tell the domain of the user(to actually serve the request agains that domain..)
I dont want to change the signature of each domain to
Test(string domain)
I cant simply access the headers since i expose the same methods both as REST and as SOAP and the authentication is different for each of them..(one is with headers as with Amazon S3 and the later is using the SOAP standard)
so basically i'm looking for a global, per call storage.(i want to avoid the Per-Call initiation method)
thanks.
EDIT:
Maybe i should use the ThreadStaticAttribute? will that work?
This will not work. You can't store anything in UserNamePasswordValidator. It even doesn't have access to OperationContext because it runs on different thread.
The way to do this is create custom message inspector and extract the information from custom message header to custom operation context extension as Frank mentioned.
WCF knows a Current OperationContext. You can write your own extensions for it. Unrelated to this issue, I used the same mechanics in this NHibernate Session management here, which may work in its concept for you as well. It accesses the InstanceContext, but the concepts are similar.

listing the functions of a web service

I wanted to make an application that will take either the path of the dll or Webservice and list me all the functions present in that dll. I accomplished the listing of the function using this but I am not able to list the functions of the Webservices. Using Assembly.GetMembers() it's listing the Function Name with the Parameters Type and I am not able to get the Parameters Name. How shall i get that? While debugging I found that m_parameters is a nonpublic member and i'm not able to get the Parameter name. Is that possible??? And one more question is how shall i list the functions available in the web service without including the web reference or service reference in the windows application using C#.
What webservices are you talking about?? ASP.NET ASMX webservices? Webservices based on WCF??
In any case, most of those web services will expose a WSDL document which basically contains the methods on the web service, plus the parameters expected for a call.
Mind you: web services don't have to publish a WSDL - it's optional. But if there is one, it's typically accessed by adding ?wsdl to the URL where the service lives, so if you want to find out what methods and parameter the prime number generator web service at:
http://www50.brinkster.com/vbfacileinpt/np.asmx
has, you do go
http://www50.brinkster.com/vbfacileinpt/np.asmx?wsdl
and grab the WSDL and start analyzing it.
To get the parameter name, use MethodInfo.GetParameters followed by ParamterInfo.Name property.

Categories

Resources