SOAP Request action - c#

Hello everyone,
I'm doing a request in SoapUI like in the photo below and I'm trying to make the same request in a SQL Server Database Project in Visual Studio...
I kind of copied the functions needed for creating the webRequest from here Client to send SOAP request and receive response but I'm kind of stuck now because of the action.
What do I need to write for the action? In my case there is a php, I'm a bit confused.
I've tried couple of things but the response remains the same.. ( -1 )
The SoapUI request
There is this WS-A panel with some info as well about the request
Also, here is my envolope for the request... just in case
I've tried adding the web reference in another project and this is what I got ( I'm not allowed to use a web reference to this unfortunately.. )
I appreciate your time spent, thank you!

Related

New Server Security Causing Issues To API Response

one of my old project/app was working fine for years, very recently client report that app does not working any longer due to API response issue.
it's just a get request to an API with some parameters..
till date (before issues occurs) it returns following response:
,,3,1669179307,0,
but recently it shows following response: (note nothing is changed in the source php/code files since project start)
<html><title>You are being redirected...</title>
<noscript>Javascript is required. Please enable javascript before you are allowed to see this page.</noscript>
<script>var s={},u,c,U,r,i,l=0,a,e=eval,w=String.fromCharCode,sucuri_cloudproxy_js='',S='bT0nP2RUNCcuc3Vic3RyKDMsIDEpICsgJycgKyAKJz9iVGYnLnN1YnN0cigzLCAxKSArICcnICsgCidIcExjJy5zdWJzdHIoMywgMSkgK1N0cmluZy5mcm9tQ2hhckNvZGUoNTYpICsgJ3FAYycuY2hhckF0KDIpKyAnJyArIAonNycgKyAgICcnICsgClN0cmluZy5mcm9tQ2hhckNvZGUoMHg2MykgKyAgJycgKycnKyIyc3VjdXIiLmNoYXJBdCgwKSsiYyIgKyAiNHNlYyIuc3Vic3RyKDAsMSkgKyAiZW0iLmNoYXJBdCgwKSArICAnJyArIAoiM2MiLmNoYXJBdCgwKSArICIiICtTdHJpbmcuZnJvbUNoYXJDb2RlKDk3KSArICJlIi5zbGljZSgwLDEpICsgICcnICsnZCcgKyAgJ0RiJy5zbGljZSgxLDIpKyAnJyArJycrJ3hJMScuY2hhckF0KDIpK1N0cmluZy5mcm9tQ2hhckNvZGUoMHgzMSkgKyAncTAwJy5jaGFyQXQoMikrU3RyaW5nL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MNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';for(u=0;u<64;u++){s[A.charAt(u)]=u;}for(i=0;i<L;i++){c=s[S.charAt(i)];U=(U<<6)+c;l+=6;while(l>=8){((a=(U>>>(l-=8))&0xff)||(i<(L-2)))&&(r+=w(a));}}e(r);</script></html>
here is curl screenshot:
And here is the postman screenshot:
and when i check the URL in browser it shows the expected result, though when i check the devtool (network tab), it looks like page is loaded two times.. 1st one provide error (HTML/js) response (read marked) 2nd one provide the expected response (green marked), so, it looks like when it's called directly by curl/postman/c#... fails.. but as browser can do redirect it passed.
here is the browser screenshot:
i am sorry, i added several screenshot to give better idea what is happening.
and here is the URL in question:
https://simpleclienttracking.com/membershipmanager/remotelogvisit.php?locID=1&orgID=1&deptID=1&barcode=8346420
now my question, is how can i use the API code/file to get the direct response as i was getting earlier? do i need to pass any header? update/modify server htaccess file or what?
To test the error in deep, i have tried another URL from another hosting provider, in that case i am passing post request to an URL, and this server response slightly different thing, but looks like core is same, redirect!
here is the response from new/another server:
<script>document.cookie = "humans_21909=1"; document.location.reload(true)</script>
so, it's looks like hosting providers has applied some kind of security for direct URL access?
thanks in advance for any upcoming help
best regards

Http response erroring out when trying to read response from server

I'm having difficulties on retrieving data from my server. I activated CORS and set up my call properly(already tested it with postman). I'm sending the post request to my server, method is being hit but when returning and trying to read the response on the client side, the SDK fails.
This is the error I'm getting on the console.
Am I missing something here? do I have to use another plugin for the htttp calls in web environment?
Error information is incomplete, in which line do you get error?
I assume your uri and some other thing are ok.
change filtereDto to:
Map<String,dynamic> filterDto={
'date':'2020-02-07....',
'countryId':'1' // string number
}
And you dont need to :
json.encode(filterDto)
in post call, only filterDto is enough
... body: filterDto ...
I have found the issue. Cors was being enabled on my server side incorrectly. Order activating Cors is critical for configurations to be applied properly in a .Net core app.
This is how is done. First activate Cors and then MVC.
Hope it helps anyone who is struggling with the same thing.

How to get the soap request going out with the call using wsdl c#?

Very new to this. I am using a wsdl. Generating the web reference and .net builds the classes in references.cs. Now is there any way I can get the soap request going out though any c# methods in my code?
Getting at System.Xml.Serialization.XmlSerializer.Serialize error in prod but absolutely working fine in UAT. No body has no clue on why? Can someone pls provide insights on getting the soap request going out ?
You can use tool fiddler to track the request and responce

C# Web Service client that will fail if WSDL is not available or invalid

My client hosts a few web services and has ASP.NET Web pages that will demo the web service and acts as a quick check to verify that the web service is up by the client. The problem is that the WSDL might be missing or invalid, but the Web Service will still work.
What I'd like to add to the ASP.NET web service client is a way to verify that the WSDL is there and valid, but have no idea where to start. Any suggestions would be greatly appreciated! Code behind is C#
I'm not entiery sure what you mean with verify that the WSDL is valid. Only thing I can suggest is, use an HttpWebRequest on the specific URI and see what response you get then either throw an exception based on specific status codes like 404 for example or handle it in a different way.
You can fetch the status code value
var request = (HttpWebRequest) WebRequest.Create("http://example.com/service.wsdl");
using (var r = (HttpWebResponse) request.GetResponse())
{
var result = r.StatusCode.ToString() == 200.ToString() ? "Success" : "Service not found";
Debug.WriteLine(result);
}
Hope this helps, goodluck.
Edit: if you know what services you're going to be testing you can simply add them as service reference in your client project and try to do an RPC on the service methods to see if it's available. Pictures below show to add a service reference.
Your scenario doesn't completely make sense. You could make a request to the service WSDL endpoint, http://something/service.asmx?wsdl and you could confirm that what comes back is a WSDL file. You could even validate it against the WSDL and XSD schemas.
This wouldn't tell you whether it was a WSDL that represented the service. It could conceivably be a WSDL for some totally different service.
Maybe more importantly, have you had problems where the service was available but the WSDL was not? In that case, rather than create diagnostics, I recommend that you fix the problem.

Client found response content type of 'text/html', but expected 'text/xml'

I am getting this error:
Client found response content type of 'text/html', but expected 'text/xml.
I am adding web reference for live search. When i build the project its Successful. But after that once i enter some text in textbox & enter search button it gives this error. I am Using my local machine & Using .net 2.0 with C#.
Plz help me...
Thanks In Advance...
As Matt said, it's probably an error page coming back.
Either use a proxy like Fiddler or a network sniffer like WireShark to see what the raw response is - that should help you get to the bottom of what's going on.
Generally that error means that the service has sent back an (HTML) error message rather than the XML SOAP response that your client was expecting.
For web services that you control it's really easy to find the problem, because you can invoke the webmethods by hand in your browser. To diagnose it when it's someone else's service is a little trickier. You might be able to trace into the code for your web reference and inspect the text of the response before the exception is thrown.
I have found Fiddler to be highly useful in debugging http client server issues.
It is a proxy that allows you to intercept and even change the content of the request and response.
In your actual code, replace the line:
searchRequest.AppID = "APP ID you generated from ...";
with the actual AppID, which should be a long alpha-numeric sequence.

Categories