.Net Core 3.1 Connected services to webservice causes fault - web-services

I want to connect to https://wsiinst.uni-login.dk/wsiinst-v4/ws?WSDL.
This works fine in normal .NET 4.7.
But in .NET Core 3.1, the channel is Fault, when creating the Client..
My steps..
create .NEt Core console App
Add Connected service (Microsoft WCF Web Service Reference Provider) , call it "ServiceRef"
Add this code to program.cs (main)
var client= new ServiceRef.WsiInstPortTypeClient();
The client is created, but state is Faulted
Perhaps web service uses something, not supported yet in core ?
Anyone have an idea or canb point me in a direction ? :-)

It's the same, when you add connected reference you click in other references, that you will get the service endpoint and you have to put the URI. you click GO and will get the service avaliable. If this isn't working that's mean you have a problem in the serverside. Did you bind your port correctly??
check this link https://learn.microsoft.com/en-us/windows-server/networking/technologies/netsh/netsh-http
after you initalize the serviveref did you open the connection?
var client = new ServiceRef.WsiInstPortTypeClient();
await client.OpenAsync();
var getanobject = await client.MyobjectAsync();

Related

Call soap web service using HttpWebRequest in Windows Store Apps

Let me clear one thing that i don't wanna use "Add Service Reference" method. I want to call a soap service using HttpWebRequest in windows store app. I have working soap web service given by my client. I only have access to the web service but not source code. I have searched the internet but couldn't find solution for Windows store app.
Thanks in advance and Happy New Year.
Why do you want to avoid using Add Service Reference? Even so, I strongly discourage you from using HttpWebRequest directly as you will lose all the benefits of having the SOAP protocol already implemented.
You can use ChannelFactory<T>, though; even from a Windows Store app:
First create the interface from the web service WSDL using svcutil.exe:
svcutil /serviceContract http://localhost:61547/Service1.svc?wsdl
Include the generated code file in your Windows Store project.
Create the channel and call a method on it from your code:
var binding = new BasicHttpBinding();
var endpoint = new EndpointAddress("http://localhost:61547/Service1.svc");
var factory = new ChannelFactory<IService1>(binding, endpoint);
var channel = factory.CreateChannel();
var result = channel.GetData(3);
((IClientChannel)channel).Close();
I tried it out with a sample web service and it worked flawlessly.

Can a wcf client handle 2 version of a SOAP response from the same url?

I imported a service reference to a SOAP web service from the customer and coded my client based on that.
After going to production, they said they will launch a new version of the web service with changes to the output type of one of the requests I make to the service (among new messages that I don't consume).
I know I can update my service reference and update my client code to process the updated wsdl and launch an update to my client at the same time the web service updates.
But, is it possible to instrument the WCF code in some way so that I can handle both versions of the response without having to coordinate the update of my client with the update of the web service?
In most cases, NO. It depends on what has changes in the service interface? In most cases you'll need (and want) to upgrade your client. You can always ask them to support more versions of their interfaces.

Disabling deployed Web services through Java code

I work with JAX-WS Web services deployed on to a Glassfish Web server and Netbeans IDE. We have provisions to disable or undeploy a Web service deployed onto a Glassfish Web server using admin console or services tab in the IDE. This looks to be some sort of hardware interrupt. I would like to achieve the same, i.e. disabling a deployed Web service through Java code, on some external command from interface. Is there any mechanism to obtain such outcome through software interrupts or by any other means?
You can keep configuration settings like discoveryAllowed attribute at server side may be like in DB.
On which you can decide whether to allow user to call web-methods. Add beelow code in web-method:
If discoveryAllowed is false then call following code:
MessageContext mc = context.getMessageContext();
HttpServletResponse resp = (HttpServletResponse) mc.get(MessageContext.SERVLET_RESPONSE);
resp.setContentType("text/plain");
resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Web service is disabled.");
If discoveryAllowed is true allow to proceed with code execution.

Consume SSL Web Service using Domino 8.0.2

Working on a project where I need to consume a web service over HTTPS (SSL) using Domino 8.0.2.
Was able to create the script library to consume the web service.
Created a simple button to test consuming it with this code:
Use "AA-FEED"
Sub Click(Source As Button)
Dim ws1 As New IAccountService_n1
Dim r1 As New ArrayOfValidSystem_n2
Set r1 = ws1.GetValidSystemsList()
End Sub
When called, Notes prompts for me to Cross Certify with your server, which I do.
That is to be expected.
Click on 'Cross Certify" button and then the web service is contacted and returns an error message:
"The Web Service IAccountService_n1 method GetValidSystemsList has returned a fault."
So...
The provider of the web serivce says when it is consumed in Java, they add certifier information to the soap header.
Not sure if the Cross Certify actions in Lotus would do equlivent in LotusScript.
If the WebService requires authentication, in your generated web service consumer code, add the following after the webservice initialize call:
Sub NEW
Call Service.Initialize ("UrnDefaultNamespaceWSQueryService", ...
'ADD THE FOLLOWING
'set userid and password if required
Call Service.SetCredentials("userid","password")
'set SSL options
Call Service.SetSSLOptions(NOTES_SSL_ACCEPT_SITE_CERTS + NOTES_SSL_ACCEPT_EXPIRED_CERTS)
Web services in LotusScript has a Java component to it when communicating (uses AXIS).
It might be that you have to put the certificate into the CACERTS. The following wiki article explains this.
http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Connecting_to_a_Domino_server_over_SSL_in_Java_using_a_self_signed_certificate._

How do I setup a asmx web service in Azure that accepts a client certificate?

I apologize in advance if the question is ridiculous.
I have an asmx service running in Azure (HTTP - no SSL).
I have a WPF app that loads a X509Certificate2 and adds it to the request by doing the following:
X509Certificate2 cert = new X509Certificate2("...");
webRequest.ClientCertificates.Add(cert);
In the web service I get the certificate by
new X509Certificate2(this.Context.Request.ClientCertificate.Certificate)
And then I load a cert (that I have both uploaded to the Azure control panel and added to my service definition file) by using the following sample:
var store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
X509Certificate2Collection certs = store.Certificates.Find(X509FindType.FindBySubjectName, certName, true);
And then I validate by doing the following:
clientCert.Thumbprint == certs[0].Thumbprint
Now unfortunately I get an exception (System.Security.Cryptography.CryptographicException: m_safeCertContext is an invalid handle) as soon as I do
Request.ClientCertificate.Certificate
So I have a few questions. How do I avoid the exception. This answer states I need to modify an IIS setting, but how can I do that in Azure?
In any case is this even the proper way to do certificate authentication?
Thanks!
You can use command scripts to modify IIS, in combination with appcmd.exe.
For a quick example (disabling timeout in an application pool), take a look at this sample by Steve Marx.
In this example, you'd call DisableTimeout.cmd as a startup task. For more info on creating startup tasks, you can watch this episode of Cloud Cover Show. There should be a lab on startup tasks in the Platform Training Kit as well.
Just remember that any type of IIS configuration change should be made via an automated task at startup. If you manually change IIS via RDP, those changes won't propagate to all of your instances, and won't remain persistent in the event of hardware failure or OS update.
You can remote into your azure instances to manage IIS. As for a way to do it globally for all instances at once, I'm not sure. That would be an interesting side project though.
http://learn.iis.net/page.aspx/979/managing-iis-on-windows-azure-via-remote-desktop/