I would like to connect to a SOAP webservice (HP Operations Manager Incident Web Service) using a .NET client based on code generated by adding a service reference. The generated proxy creates a client that implements the DuplexClientBase class. The service is IIS hosted with a self-signed certificate and I need to sign in using basic authentication.
I ran into two problems trying to connect to this service:
I have not yet been able to find the right binding configuration. Either the binding does not support duplex or https traffic with basic authentication.
When adding a .NET 2.0 web service reference (the binding issue is not there) I am able to connect to the service but the “Action” header element which is required by the service and should look like <a:Action s:mustUnderstand="1"> http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate</a:Action> is not included in the header. When I create a SoapExtensions and inspect the contents of the Action property of the SoapMessage object in the ProcessMessage(SoapMessage message) method it contains the right value but the property is not serialized in the message header.
I would like to know if any of you could suggest what to do:
Proceed with a 2.0 legacy reference and find a way to add the Action element in the SOAP header. (eg adding a SoapExtension)
Fix the binding a find a way to connect to the https site with faulty certificate (wsDualHttpBindingdoes not support HTTPS, BasicHttpBinding does not support duplex, PollingDuplexHttpBinding does not seem to work in a console application)
Try to generate the code in a way that no duplex communication is required. Is this possible?
It is possible to make a .NET 2.0 client support WS Addressing. You can accomplish this by downloading and installing Webservice Enhancements 3.0 (WSE). http://www.microsoft.com/en-us/download/details.aspx?id=14089
When you add a reference to the Microsoft.Web.Services3 assembly and change the code generated by adding the web service reference. Change System.Web.Services.Protocols.SoapHttpClientProtocol into Microsoft.Web.Services3.WebServicesClientProtocol and the code will support WS Adressing. The action element will now be added to the SOAP header.
Although this workaround does the job I still would prefer a WCF service reference connection.
Related
I have an ASP.NET Core application hosted on a server which doesn't access the internet directly for security reasons. So if I used any SDK (ex: FCM SDK) it can't initialize a connection from the application.
The SDK is internally calling an API like fcm.googleapis.com; I need to create something which intercept the SDK request and forwards the request to this route (ex: 192.168.1.45:51514) and I configure the proxy to navigate to the desired URL.
I'm thinking for multiple solutions as follows:
Create a middleware that intercept the SDK requests and changes its base URL to the desired URL (I don't know if it'll work or not).
Create an intermediator project which I can call and just call it then the SDK integration inside the intermediator project (it works but searching for a better solution).
Get the SDK source code as it's an open source and change the URL to be configurable not hardcoded as it is.
Please advise for what is the best practice solution for this issue.
I have access to WSDL file of a specific web service that contains a SendData method - basically I specify the TimeStamp and Value to be send. I uploaded the WSDL file to my project in Visual Studio 2019 as a connected service (Add->Connected Service->Microsoft WCF Web Service Reference Provider->Browse->I added location of the WSDL file and specified the service that included SendData method). After that I created a new client:
ServiceSoapClient client = new ServiceSoapClient(ServiceSoapClient.EndpointConfiguration.ServiceSoap);
added credentials (the web service requires login):
client.ClientCredentials.UserName.UserName = "test"; client.ClientCredentials.UserName.Password = "test";
created a new variable Data that contains TimeStamp and Value (in a specific format required by the method).
After that I invoked the method:
client.SendData(Data);
but it doesn't work. There are no errors or exceptions thrown, but the Data is not visible on the web service (the web service also has a GUI). I started to wonder if it is possible to send data to a web service in such a way or is it maybe necessary to create an xml file with a request and use HttpWebRequest?
Perhaps someone could help me figure out what is wrong, is there a way to check, what is going on during compilation? Unfortunately, I cannot include the URI or WSDL file, but hopefully my description of the issue will be sufficient. Thanks in advance for any guidance!
Okay, with the suggestion from Robert Harvey (thank you once again) and some trial and error I managed to solve my problem. Hopefully my answer will be useful to someone with the similar issue.
I found out that in some cases WCF web service's calls are not visible in Fiddler. In my case it was due to some packages not being up-to-date. These out-of-date packages were added automatically after connecting the web service via Microsoft WCF Web Service Reference Provider.
System.ServiceModel.Duplex/Http/NetTcp/Security all were installed in version 4.4 instead of 4.7. I updated them using Project->Manage NuGet Packages and now my requests are visible in Fiddler and I managed to verify that the way I used my method was correct, but the access to the web service (with the ability to save data) is currently limited, that is why the result was not visible directly on the web service (in the GUI).
I'm trying to replace a WCF service based on BizTalk and as far as I know it was made using the BizTalk wizard for publishing WCF services. In order to resolve the problem I did something tricky, I exposed an ashx handler and read the soap. We want the department that consumes the service to not make any change except the url (.svc-> .ashx) and maybe another minor change like change binding. The problem I have now is the message for some reason uses more than one soap request with security tokens like:
I suppose is related to the service model configuration (credentials i think) in the WCF client,
Is there any way to force the binding in order to send just only one no encrypted-request?
As a quick run-through, i've got the following scenario
Website which hosts c# web api services
each webapi takes a 'request' message type and returns a 'response' message type
Also a winforms client app which has its own repository that consumes the webapi services for its own use.
Is it good practice to put the request/response messages in a shared library which will be used by both the website, and by the client app bearing in mind if i update the webapi on the website, it could get out of sync with the distributed client apps, and may break functionality for them until they upgrade to the latest version.
thanks for any suggestions.
If you cannot force your clients to update to the latest version, I would create a new endpoint with a corresponding shared library for each breaking change.
http://yourservice/api/v1/GetXY
http://yourservice/api/v2/GetXY
http://yourservice/api/v3/GetXY
....
And you could set up monitoring to see which old/obsolete endpoint is not in use anymore and turn it off if you want.
I'm using VS 2012. My server side is WebApi 4.5 and my client side application is WPF.
I want to consume my odata service at the client side using "Add Service Reference" but I don't know how to generate the metadata file.
You should point it to the root of your OData endpoint. If you're using the default routing, it's http://<address>:<port>/odata. If you've got a different routing, you should check your MapODataRoute line in WebApiConfig.cs.
Clarification edit:
The metadata itself can be found at http://<address>:<port>/odata/$metadata. However, as I said, in order to add it as a service reference, it should be sufficient to point just to the root.