BizTalk does not call WCF service - c#

I have created a local WCF service which has a method InsertOrUpdate(String) which connects to a database and insert/update the data. If I run this service with the tutorial code from here (8) and test it with the WCF Test Client from VS 2013 all works great.
Now I want to call this method via a BizTalk Server application so I have saved the WSDL file from the service and imported it into my BizTalk project via the consume WCF service wizard. Then I have created a small orchestration which looks like this:
The in port points to a directory on my hard drive and looks for all kinds of xml files. The out port is set as HTTP transport to http://localhost:43250/Services/MyService.svc. I have signed and deployed the BizTalk applicationon my local machine and if I put an xml file in the port directory it disappears after a short time but my service is not called. In the BizTalk Management Console I get following error:
The published message could be not forwarded because no subscribers
were found. This error occurs when the subscribed orchestration or
subscribed Sendeport were not registered or some necessary to check
the subscription message properties were not promoted. To resolve this
error, use the BizTalk Administration console.
I'm sure that the XML file is valid and the pipelines are set to XML Receive/Transmit too. Do you have any ideas why it is not working? All this happens on a locale Win 7 x64 machine.

These are the first things I would check in this situation:
0. Restart all your host instances and retest.
When you deploy a Biztalk project, assemblies go in the GAC. Biztalk needs the host instances using these assemblies to be restarted or it will keep using the old ones.
You actually don't need to restart all the host instances, but for the sake of simplicity, try it.
1. Make sure all your deployed items are green
Go in the Biztalk administration console, make sure that:
the orchestration is bound is your Receive and Send port (right
click-> Properties -> Bindings)
the orchestration is enlisted
the SendPort enlisted
2. Make sure your input file is right
When you imported your WCF service in Visual Studio, it should have created XSD files to define the schema you can use.
Right click on the XSD file in TFS and click "Generate Instance".
Now go get the file generated and use it as your input.
If it works now with that file, your test file has a problem.
3. Check the subscription of your send port:
Open the Biztalk admin console
Open "Biztalk Group", click new query and search for a "Subscription"
having the same "Service Name" the same name as your Send Port
The subscription is a filter to decide whether a message will go
through your port or be ignored.
If you bound your SendPort, the filter will be a Boolean
expression uniquely identifying your port, using the property BTS.SPTransportID

Does the whole process won't activate ?
Maybe your input schema doesn't match your input xml.
Please validate your XML against the schema, and then redeploy your project.
Make sure the input port is configured to "XMLReceive", because that pipeline promotes the "MessageType" to the context.
Not sure if you should use "XMLTransmit" on the ws port.
You can also check the message subscriptions via BizTalk Administration Console.

Related

Deploy a callback API to a VM with IIS

I am hoping to deploy a web api to handle callbacks from a 3rd party.
I'm a beginner at C#, but I've written a simple Web API using Visual Studio in order to handle the callbacks.
To test on my dev machine I click the green run button with IIS selected on localhost, and the dll is created. I can feed it some 3rd party test JSON files (using Postman) and the database is updating correctly. So far so good.
Now I'm looking at deployment to a test server, which can receive live (test) callbacks. To do this, I've run up a new VM with a public IP address, installed SQL Express and also installed IIS.
I am assuming the next step is to publish (web deploy) from VS.
But I'm becoming confused with regard to domain name, URL and IP address.
a) Do I need to register a domain name for the IP address? (There is no UI, just the callback endpoint)
b) When setting up the publishing profile for web deploy, what is the Destination URL?
There is a lot of information available on the subject, but there are clearly a few important gaps in my knowledge, and I can't seem to fill 'em.
Thanks
If I am understanding your question correctly - no you do not need a domain name to test your application. You can use a tool like Swagger to test your API. Read more here: https://www.blazemeter.com/blog/getting-started-with-swagger-ui
Good luck!

Service fabric endpoint port configuration

I want to deploy multiple instances of service fabric application to one service fabric cluster. In order to do it I need to have ability to configure port in service manifest (so different instances are running on different port). Every example which i seen use 'hardcoded' value in this file. Is it possible to have it configured in ApplicationParameters or in Settings.xml file ?
Another option which I consider is to use tokenization to solve my problem (so i have token in service manifest, which will be replaced by tokenization task during VSTS deployment). But in that case I don't have simple way to run service locally in Visual Studio (or maybe I have ? I will also appreciate suggestions how to do it).
Thank you in advance.
It is not possible to override the port. If you do not care about a particular port, leave it blank or set to 0. We are working on allowing to override the port.

Adding Web Refrence to Visual Studio while Connected to VPN

i am connected to my clients network using vpn.
I need to use a exposed webservice of the Project server in their network.
when i tried the url http://server:port/service.asmx?wsdl in browser i get the wsdl.
But when i try to add web refrence in visual studio i says There is a error downloading the http://server:port/service.asmx?wsdl.could not resolve proxy.MycompanyDomain.com.
Why it is not by passing my company's domain. How to resolve it.
You could create a concrete WSDL by downloading the file from your browser and crating your web reference against the WSDL file rather than against the URL. This can be useful when you want to be sure you have a copy of the service interface at a point in time (particularly if the service is third party and may have unexpected changes that you want to flag back to them).

Programming against WSDL without access to actual webservice

I'm going to use C# to read data from a few webservices. I've done that many times before, but those times I've had direct access to the webservices from my development machine.
In this project I've just been sent a .wsdl file, and a couple of .xsd files for the webservice they have in their local intranet.
I've seen that I can use "Add Web Reference", and point directly to the .wsdl file, so that a C# class is created.
But how can I really test it? I'd like to return some dummy data that I can visualize while I develop. Any tips for this situation?
Mock Webservice
From the above source, a .cs file can be generated by opening a Visual Studio Command Prompt and running something like the following:
wsdl /language:CS /namespace:Your.Namespace.Here
/out:Directory\To\Save\To\ /protocol:SOAP /serverinterface
finally-your-wsdl-file-here.wsdl
You can also try SOAP UI for mocking up service with ease. (Free web service testing tool)
Check:
http://www.soapui.org/gettingstarted/mocking.html
The svcutil.exe tool bundled with the Windows SDK (found at C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin) is a nice command line tool that generates WCF client proxies. I've found this to be a good way to interrogate a WSDL. It'll create an interface for the service and then a proxy class that implements that interface. You can then mock up something else that implements that interface to facilitate testing.
It is easy to create your own server side stub. Assuming you want to do it with WCF, then go here. You can then add some basic logic to get your client working.
You can also use the legacy Web Service functionality via the WSDL tool's /Server option, though I recommend you use WCF.
You may also want to try a product like "Fiddler" (http://www.fiddler2.com)
It allows you to capture HTTP (or HTTPS) packets and send a fake automated reply file back as if the server had sent the response. I use it for my project and it works wonders when the test server goes offline (which is often). I take an old response packet, save it as a text file, then send it back again and the application I'm building has no idea it didn't come from the actual host.
I've also found this article very useful: https://ivangrigoryev.com/en/how-to-mock-a-web-service-in-dot-net/
It describes the steps needed, from downloading the WSDL file and to the creation of the test project:
Get WSDL somehow
In the VS Command Prompt:
wsdl /language:CS /out:C:\Downloads\ /protocol:SOAP /serverinterface C:\Downloads\webservice.wsdl
Create a new ASP .NET Web Application with an empty template
Add the file, generated on step 2, to the project
Add a new service to the project (Add -> New item -> Web Service (ASMX))
Change the class definition in the code for this added web service, so it implements the right interface, e.g replace System.Web.Services.WebService with yours.
Hit Alt+Enter and implement the interface automatically with stubs.
Hit F5, the service will run and your browser will open, copy the URL and use it instead of the real URL.
This works only in .Net Framework since .Net Core and .Net 5 dropped the WCF server support. But I found it acceptable to have the main project on .Net 5, but this mock service on .Net Fw 4.8

Passing a Windows Service Parameters for it to act on

I want to turn a program I have into a service so I can use it without logging it. Basically what it does is it backs up specified folders to a specified location using SSH. However the problem I'm running into is I don't know how to tell it these items. I only know how to start, stop, and run a custom command with only an integer with a parameter.
How can I do this?
Windows Service, not a Web Service
edit: The folders it backs up will not remain consistent and will be updated at every runtime
You can instantiate your service and pass command line arguments using the ServiceController class.
using (ServiceController serviceController = new ServiceController(serviceName))
{
string[] args = new string[1];
args[0] = "arg1";
serviceController.Start(args);
}
"arg1" will then be available as regular command line arguments in main() when Windows starts up the service.
I see that you (or someone) voted Sebastian Sedlak's answer down, because he mentioned hosting a WCF Service in the Windows Service. Your reply was
It's in nice bold lettering in the question. Not a Web Service, therefor WCF is out of the question
I think you misunderstood what he meant. He wasn't talking about a Web Service. He was talking about hosting a WCF Service within your Windows Service.
It's far from the same thing. You can host a WCF Service within any Windows (Forms/Console/Service) application. The point of doing so, is that the application is then reachable for communciation via its internal WCF Service, in the same fashion as you can communicate with a Web Service (you can also host WCF Services in IIS, btw, which would then make them "Web Services", in the sense you seem to be referring to).
In a Windows Service, this means you can send any command to it and also get any information you want from it - while it's running.
In fact, I am working on a project right now, which is a Windows Service that I need to be able to contact and pass commands to - and get information from - at runtime. For example, I want to be able to tell it where to store certain things, what to log, to have it reset/restart - and poll it for status messages. I do this by hosting a WCF Service inside the Windows Service. That WCF Service exposes a set of methods, that in my case includes receiving commands and returning status information. So when the Windows Service is running, I can contact it (even remotely), via its built-in WCF Service and tell it what to do.
This an extremely easy thing to implement, and in the case of Windows Services, can provide you with a much richer interface to the Service than through the basic standard commands.
However, you specified that you wanted your Windows Service to receive its folder settoings each time it starts up, which makes such a passive setup less than ideal (as it would be unable to do anything until you passed it the right folders).
One way to deal with this (using a hosted WCF Service), would be to have the Windows Service running all the time (i.e. automatic startup). Its default state would be idle. Then you could issue it a "start processing"-command, feeding it the correct folders to work on (through a call to the corresponding WCF Service method). Similarly, the WCF Service would expose methods giving you the status of the application (current folder, progress, busy/idle etc). Once the processing is done, it would go back into the idle state, waiting for the next set of folders to be supplied to it.
Doing it this way would make it very easy to control remotely - you could even make an online administration panel for it, accessible from anywhere.
The issue, is that, while passing in parameters is not difficult, when the machine restarts and windows tries to restart the service, those parameters are not there. they only exist when someone starts the service from the command line.
for example. I have a windows service which hosts a WCF service. I want the users to be able to specify a non-default port number for the WCF service to listen on. They do this by starting the windows service like so... MyService -port:xxxxx
Which works fine, until the server is rebooted, then windows restarts MyService (but without parameters) and the wcf service defaults to original port #
Any service is capable of receiving command line arguments at start-up.
Would it be possible to use a configuration file to specify these items?
Store the service's startup parameters in the registry: and then, when the registry starts, it should read its startup parameters from the registry.
Windows services have executables like any other. I believe you can write it to accept command-line parameters and specify those parameters in the Windows Service configuration. You can also have it read a config file. If you're using .NET, there are config file classes in the framework.
Why not just Host a WCF Service in the Windows Service to obatain such "admin" functions?
(Remoting is also possible)
RE: config file.
Of course a config file can be used.
And the file can be changed while the service is running.
This would be a nice solution if the config file changes in fact.
All my services use an XML config file, wrapped in a class for easy reuse.
The wrapper has an option to monitor the XML file using fileMonitor for changes, optionally refreshing the content of the config file automatically, and finally raises an event to the service class.
The service then has the option of "resetting" itself as needed to incorporate the new values in the XML configuration file.
Placing configuration into the registry has a few issues:
Security (ie: installer being granted access), depending on what tree is used
The service will not be aware of changes
Portability - although minor as the install should setup registry settings
Where an XML file is easy to copy, edit, share, view and understand.
Throw in some good COMMENT blocks and a detailed XSD file, and it becomes a source of good documentation too.
Look into XPath for easy navigation and extraction of values within the XML file.
$0.02
... david ...
Concerning the app.config file - I'm rather sure that your service will read and use those files as I write all my windows-services this way ;)
So just put everything you need in the app.config under "application" (not user) and put allway edit the "yourname.exe.config" in the folder where you "InstallUtil" the service from.

Categories