Tuesday, February 17, 2015

Sort blocks in the StreamServe

Some instances we need to sort blocks in the stream server mom development. Think a scenario like below. I have stream file in below architecture.

2M

1L

1L

1L

2M

1L

2M

But I need to print it like below,

1L

1L

1L

1L

2M

2M

2M

There are several way to achieve this task.Doing by MAK is very extensive task.So here im going to play with block sorting option.

I  use PMS241 as my demo project.

First go the event.and double click on it

image

Identify the blocks that you want to sort and apply the sort block priority as below.(In my case case blocks are PMS2414L and PMS2414M.

Set 4L block priority

image

Set 4M block priority.

image

We are done now.Block sort priority lower one come first.That means number is low, then it is get prioritized. same as the M3 print out sorting order.

Finally save and deploy. It should work.  Smile

Thursday, February 12, 2015

Adding site binding gives object null reference error in IIS7

Recently I have tried to add new binding to the my existing site using IIS GUI. But when fill the relevant information and click ok button its ended up with prompting object null reference to me.

image 

But I could not find solution for this but found the another way to do the same task using Appcmd.exe(only available in IIS 7 or above). I want to add new net.tcp biding to the site and I ran below code in the command prompt(please make sure to run comman prompt as Administrator mode- other wise there will be another errors.).

appcmd set site /site.name: contoso /+bindings.[protocol='https',bindingInformation='*:443:'].

Wednesday, February 11, 2015

How to hide overlay in StreamServe

In some times you have to hide the overlay in stream serve dynamically. For a example if the activity is print you want to skip the overlay and if its mail need to continue with the overlay.But in this case you cannot use normal Skip function as overlays are static content. But there are several ways to do this task and in this post am going tell you to do this via a variable which is used the the overlay properties.

So first you have to go to the overlay properties and assign variable for it.

Untitled

image

Assign variable name as mentioned above(you can have any name for the variable and same should use in the script part.) Please make sure to Tick the “supress overlay” check box.

Now we are done in the overlay.

Then move the Body or what ever page that you use the overlay and add a script before page load event and apply below code.

In this example I going to skip the overlay when the activity is prints

if(&mvx_activity ==”PRINT”){

$prabodha = “TRUE”;

}else{

$prabodha = “FALSE”;

}

Bingo it should work.

Friday, August 15, 2014

System.BadImageFormatException: Could not load file or assembly(Windows service)

Recently I have created a windows service and I wanted to to install that service to the my QA server.for that I used InstallUtil command.So for that below command in my command prompt.

image

But that command failed with below message

System.BadImageFormatException: Could not load file or assembly '{WriteOffService.exe}' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Then after my check dependencies those were placed fine.After I search I found the reason for this. Smile

I have complied my application according to the 32 bit configuration and I used 64 Bit installUtil to the install application. after I installed it using 32 bit installUtil and its worked as expected.

After you install .Net framework(in my case it is version 4.0) its created the two separate folders for 32 bit and 64 bit.In side those folders for according to the Framework version

Intallation root:\Windows\Microsoft.NET\

 image

(here you can see two different folders Framework(32) and Framwork64(64)).That each folder contains two InstallUtil versions according to the .Net Framework version.

image

64 bit version

image

32 bit version

Monday, April 7, 2014

WCF Discovery : Ad Hoc Discovery Client

WCF Discovery is a new feature which was shipped with WCF 4.0.WCF discovery is an implementation of the OASIS WS-Discovery specification.Think a scenario where  client application has the address of a specific service hard-coded into its configuration, then if that service moves, becomes temporarily unavailable, or is just too busy to handle requests, the client will not be able to communicate with it. WCF provides discovery and routing to address these issues. By implementing discovery client Application can locate the specific service address dynamically. As well as service can broadcasts its status to the all clients when service goes down or up.

There are two ways to implement WCF discovery.

  • Add Hoc Discovery
  • Manage Discovery

In this example I m going to explain Add Hoc Discovery client.In this client, service address not hard coded.Instead of that setting up the client endpoint address dynamically.

How this works ?

In Adhoc model clients send Probe message to the network .This message contains the information about the service which it wishes to connect. After service receives a Probe request, it can examine its contents, and if the probe matches the contract implemented by the service, it can respond to the client with a ProbeMatch message. TheProbeMatch message contains the service addressing information that the client needs to connect to the service.Client message uses the UDP protocol to send the probe message.

When implementing in order to  support above model service need to add specific endpoint call udpDiscoveryEndpoint and Service Discovery behavior to the service behaviors

what is udpDiscoveryEndpoint – This is a standard endpoint which used to implement the ad hoc mode of discovery.

<services>
<service name="Discovery.PTSService" behaviorConfiguration="discoveryBehaviour">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="httpBinding"
contract="Discovery.IPTSService" />
<!—new discovery endpoint-->
<endpoint kind="udpDiscoveryEndpoint"/>
</service>
</services>


What is Kind ?


udpDiscoveryEndpoint is standard endpoint .if we need to use standard endpoint we have to use kind instead of name. for more information http://msdn.microsoft.com/en-us/library/ee358762(v=vs.110).aspx


<serviceBehaviors>
<behavior name="discoveryBehaviour">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />

<!-- service dicovery behaviors -->
<serviceDiscovery />
</behavior>
</serviceBehaviors>


Additionally we can set the scope for the service endpoint behaviors.which Adds the scope information for the endpoint that can be used in matching criteria for finding services.


Now our service is completed.(please make sure service is up and running)Now move the client implementation.


image


Client need to have reference to the System.ServiceModel.Discovery and your service.


image


static void Main(string[] args)
{
//initialize new discovery Client with UdpDiscoveryEndpoint
DiscoveryClient client = new DiscoveryClient(new UdpDiscoveryEndpoint());

// define the find criteria with serivce type
FindCriteria criteria = new FindCriteria(typeof(IPTSService));

// then clinet .Find
FindResponse services = client.Find(criteria);

client.Close();
}


Additionally FindCriteria can set the time out for service discovery. whether criteria can find service or not its return the output after the specified time.


criteria.Duration = TimeSpan.FromSeconds(50);


Lets run and see what happens.I have put watcher to the my services object..


image


Now you can see Find response contains all the required for the service invocation.

Thursday, April 3, 2014

The type 'System.ServiceModel.Routing.RoutingService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found

Recently I have created WCF router service and deployed to IIS. But once I run the my router service its gives me above error Sad smile.Normally this kind of errors happen when service couldn't find the service host reference. but in my router service its seems ok .

<%@ ServiceHost Language="C#" Debug="true" Service="System.ServiceModel.Routing.RoutingService" %>


Then I use full qualified name instead of the name as below.Bingo then its works Smile 


<%@ ServiceHost Language="C#" Debug="true" Service="System.ServiceModel.Routing.RoutingService,System.ServiceModel.Routing, version=4.0.0.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35"  %>

Wednesday, April 2, 2014

This message cannot support the operation because it has been copied

In order to implement few validations I have written separate method which expects message instance as parameter. In side that method I process the  input message . but once I try to run my service it throws above error and terminates the process Sad smile. after spending some time with the issue I could identify the issue.

according to the MSDN The body of a Message instance can only be consumed or written once. but I have tried several times to read message instance inside my validation logic.

from MSDN

“You can access the body of a Message only once, regardless of how it is accessed. A message object has a State property, which is initially set to Created. The three access methods described in the preceding list set the state to Written, Read, and Copied, respectively. Additionally, a Close method can set the state to Closed when the message body contents are no longer required. The message body can be accessed only in the Created state, and there is no way to go back to the Created state after the state has changed.”

There fore we need to use CreateMessageCopy method for reading the message.

   1: public bool Logic(Message message)
   2: {
   3:     MessageBuffer buffer = message.CreateBufferedCopy(Int32.MaxValue);
   4:  
   5:     var message1 = buffer.CreateMessage();
   7:  
   8:     buffer.Close();
   9:  
  10:     return true;
  11: }

Bingo its works Smile