tag:blogger.com,1999:blog-86158693725439310372024-02-20T21:18:38.676-08:00Tech BarahaRaveesh Kumarhttp://www.blogger.com/profile/02898028390727186228noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-8615869372543931037.post-2681457368504431092015-12-03T08:22:00.002-08:002015-12-03T08:32:20.902-08:00Handling CDATA in JAXB without escaping<div style="line-height: 1.5; text-align: justify;">
JAXB by default escapes characters inside a string in the Java model when it converts the Java model to XML. This creates issues if you have CDATA present in the string. You will have even the CDATA tags escaped <span style="line-height: 19.2px;">[i.e <![CDATA[&lt ]</span><span style="line-height: 1.5;">, which makes it difficult for the consumer of the final XML for processing. So, to avoid this and to handle CDATA in JAXB the way you want, there are 3 approaches :</span><br />
<ol>
<li><span style="line-height: 1.5;"><b><u>Using XMLSerializer and OutputFormat : </u></b> Usage of this can be found in <a href="https://jaxb.java.net/faq/JaxbCDATASample.java">here</a>. In the OutputFormat, one can specify the elements to be treated as CDATA. But both these classes XMLSerializer and OutputFormat - have been deprecated since Xerces 2.9.0. Latest Xerces version is 2.11.0. Following is what the Xerces documentation says :
<i>This class was deprecated in Xerces 2.9.0. It is recommended that new applications use the DOM Level 3 LSSerializer or JAXP's Transformation API for XML (TrAX) for serializing XML. See the Xerces documentation for more information.</i>
Ref <a href="https://xerces.apache.org/xerces2-j/javadocs/other/org/apache/xml/serialize/XMLSerializer.html">https://xerces.apache.org/xerces2-j/javadocs/other/org/apache/xml/serialize/XMLSerializer.html </a><a href="https://xerces.apache.org/xerces2-j/javadocs/other/org/apache/xml/serialize/OutputFormat.html">https://xerces.apache.org/xerces2-j/javadocs/other/org/apache/xml/serialize/OutputFormat.html</a></span></li>
<li><span style="line-height: 1.5;"><b style="text-decoration: underline;">Using XMLAdapter and Character Escape Handler : </b> In this approach, one needs to </span></li>
<ol>
<li>Specify Adapter class in the bindings.xjb for String element to be handled as CDATA. You can find how to specify it <a href="http://stackoverflow.com/questions/7837451/specify-xmljavatypeadapter-class-via-bindings-file">here</a>. In the adapter class, in the marshall method one needs to add CDATA tag to the argument string.</li>
<li>During marshalling of the javamodel by JAXB, one needs to specify CharacterEscapeHandler which can handle CDATA element without escaping. You can find usage <a href="http://stackoverflow.com/questions/14193944/jaxb-marshalling-unmarshalling-with-cdata">here</a>. Any other special handling like escaping in certain cases, also need to be handled. This is a nightmare to maintain.</li>
</ol>
<li><span style="line-height: 1.5;"><b><u>Using JAVAX XML Transformer APIs : </u></b></span><span style="line-height: 1.5;"> <span style="line-height: 19.2px;">You can find the usage of this approach <a href="http://stackoverflow.com/questions/31483165/marshalling-cdata-elements-with-cdata-section-elements-adds-carriage-return-char">here</a>. I</span>n this case, Javamodel from JAXB would be marshalled into a DOM document(w3 doc). Then, it would be transformed into XML string the way we want by JAVAX Transformer. In the Transformer, we can specify the list of elements to be handled as CDATA.</span></li>
</ol>
<div>
I would recommend using the third approach since it is configurable, easy to maintain and part of standard Java package. </div>
</div>
Raveesh Kumarhttp://www.blogger.com/profile/02898028390727186228noreply@blogger.com0tag:blogger.com,1999:blog-8615869372543931037.post-35670826127835238042012-05-18T22:45:00.001-07:002012-05-18T22:47:54.856-07:00Solution for web pages with white spaces failing in Internet Explorer 9 (IE9)<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="line-height: 1.5; text-align: justify;">
If you have a webpage with white spaces/new line character between the ending of one html tag and beginning of another, then chances are there that it may not display or work properly in Internet Explorer 9. I checked the html code generated for Internet Explorer 8(where it works!) and Internet Explorer 9. There is no difference. Then what has gone wrong?<br />
<br />
<b>Issue : </b><br />
<ul>
<li><span style="line-height: 1.5;">Internet Explorer 9 is conforming to HTML 5 specifications. Accordingly HTML parsing has been changed in IE 9.
One change that affects almost every page is how whitespace parsed. While IE8 removes or collapses whitespace, IE9 persists all whitespace into the DOM at parse-time. </span><span style="line-height: 1.5;">Refer to the following link for more details : </span><a href="http://blogs.msdn.com/b/ie/archive/2010/09/13/interoperable-html-parsing-in-ie9.aspx" style="line-height: 1.5;">http://blogs.msdn.com/b/ie/archive/2010/09/13/interoperable-html-parsing-in-ie9.aspx</a><span style="line-height: 1.5;"> </span></li>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiy3AM5zoKWK28w4To1_DhCc_ZUt3QeU7Nfl-o51IBuaYWGkMHnD7ibfYuX1elqE0b_rk6Qv0jdjkSByq1Md4A1XnH2FFHlWKGy9y0vd7bt_Qqa4I24lTdvCCJrFgu8rNLCq8dmcDs9Ne9S/s1600/HTML5-logo.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiy3AM5zoKWK28w4To1_DhCc_ZUt3QeU7Nfl-o51IBuaYWGkMHnD7ibfYuX1elqE0b_rk6Qv0jdjkSByq1Md4A1XnH2FFHlWKGy9y0vd7bt_Qqa4I24lTdvCCJrFgu8rNLCq8dmcDs9Ne9S/s1600/HTML5-logo.jpeg title="HTML 5 logo" alt="HTML 5 logo" /></a></div>
<li><span style="line-height: 1.5;">So, if you have java script code which accesses the nodes in DOM ignoring the white spaces previously, then you are bound to be in big trouble. In IE9, all the white spaces/new lines in DOM are treated as nodes. So, when you traverse using APIs like firstChild may not reference to the element you might have intended.</span></li>
</ul>
<br />
<b>Solutions :</b><br />
<br />
<ol>
<li><span style="line-height: 1.5;">If you want to traverse elements (ignoring the white spaces) only then use </span><i style="line-height: 1.5;"><a href="http://www.w3.org/TR/ElementTraversal/">Element Traversal APIs</a> -</i><span style="line-height: 1.5;"> c</span><span style="line-height: 1.5;">alling functions such as </span><i style="line-height: 1.5;">nextElementSibling</i><span style="line-height: 1.5;"> to ensure that you don’t reference a stray newline character or white space by mistake.</span></li>
<li><span style="line-height: 1.5;">On the other hand, make sure that your code is backward compatible with previous browser versions by adding check for the same while traversing the elements in DOM</span></li>
<li><span style="line-height: 1.5;">Removing the white spaces - this is a tedious job, as you would be doing the work of the browser done previously. But here you don't need to have the check for Internet Explorer browser versions. </span></li>
</ol>
</div>
</div>Raveesh Kumarhttp://www.blogger.com/profile/02898028390727186228noreply@blogger.com0tag:blogger.com,1999:blog-8615869372543931037.post-62027747715182251632012-05-15T10:50:00.001-07:002012-05-15T10:54:37.309-07:00How to avoid GetSaveFileNameW failing in IE9 in Windows7?<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
<div style="line-height: 1.5;">
<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms646928(v=vs.85).aspx">GetSaveFileNameW</a> is a Windows API. It creates a Save dialog box that lets the user specify the drive, directory, and name of a file to save. I had a ActiveX plugin which was using this function to get the name of the file user is saving. It was working fine in IE8 in Windows XP but it started failing in IE9 on Windows 7. It did not create a dialog box and returned error!</div>
<div style="line-height: 1.5;">
</div>
<br />
<b style="line-height: 24px;">CommDlgExtendedError : </b><span style="line-height: 24px;">When inquired through <i><a href="http://www.blogger.com/"><span id="goog_1430753915"></span>CommDlgExtendedError<span id="goog_1430753916"></span></a></i> about the reason for failure of <i>GetSaveFileNameW</i>, it said error code : 0xFFFF</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcdRJ6GIYz94BFbftTi8MelfzEN-Jdg80hQCBpImyzvBfonpT2XEYkLCFigy3cCOXOXAbrkOM6rVI1cfdSOaDoqr0LpZXZvI1Q_XQWpASAm7yljc1jldKBrKCRGujfR01B7DMQd6fFI2Pn/s1600/IE9_Logo.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Internet Explorer 9 logo" border="0" height="234" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcdRJ6GIYz94BFbftTi8MelfzEN-Jdg80hQCBpImyzvBfonpT2XEYkLCFigy3cCOXOXAbrkOM6rVI1cfdSOaDoqr0LpZXZvI1Q_XQWpASAm7yljc1jldKBrKCRGujfR01B7DMQd6fFI2Pn/s320/IE9_Logo.jpg" title="Internet Explorer 9 logo" width="320" /></a></div>
<span style="line-height: 24px;"><b>Explanation for error code 0xFFFF(CDERR_DIALOGFAILURE)</b> - The dialog box could not be created. The common dialog box function's call to the DialogBox function failed. For example, this error occurs if the common dialog box call specifies an invalid window handle.</span><br />
<br />
<span style="line-height: 24px;"><b>Debugging : </b>Internet literature provided little help. Then,<b> </b>I checked whether this function - <i>GetSaveFileNameW</i> - worked fine for a standalone application. It did and then tried with the same set of parameters in ActiveX plugin. But it did not work for ActiveX plugin </span><br />
<br />
<span style="line-height: 24px;"><b>Reason for failure :</b> Later I found that IE9 was not fully supporting the ATL version I was using. <i>GetSaveFileNameW</i> was failing because of the flag OFN_EXPLORER. How?</span><br />
<br />
<span style="line-height: 24px;"><b>Solution : </b>OPENFILENAMEW structure is filled before passing as a parameter to <i>GetSaveFileNameW</i>. Here, we set the flag OFN_EXPLORER in the Flags attribute of OPENFILENAMEW structure. If the OFN_EXPLORER flag is set, the system uses the specified template to create a dialog box that is a child of the default Explorer-style dialog box.
If the OFN_EXPLORER flag is not set, the system uses the template to create an old-style dialog box that replaces the default dialog box. I was setting the flag - OFN_EXPLORER. I now reset the OPENFILENAMEW and it works!!!</span></div>
</div>Raveesh Kumarhttp://www.blogger.com/profile/02898028390727186228noreply@blogger.com0tag:blogger.com,1999:blog-8615869372543931037.post-86041150229164183982011-12-26T01:55:00.000-08:002011-12-26T01:57:23.945-08:00Workaround for old Firefox Plugins crashing on Windows 7<div style="line-height: 1.5; text-align: justify;">
I had an old plugin which was working fine in Windows XP. When I moved to Windows 7, this plugin kept crashing whenever opened. After a while, I was able to find a workaround for making this plugin work.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjB6JCrRFtZCtRvWSGNrMpsUVljHrMG3TkA7Ml_c6x2EvsOqT2ZZFd-9IxYjOypR8fGvW4DYglSDXSZy0TklWrKbFvb5d7GTaPPIlx7vSj1jaxKc2c7J26_Ry4_IUz6CpjIVUrtO-HH8l55/s1600/Windows7.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Windows 7" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjB6JCrRFtZCtRvWSGNrMpsUVljHrMG3TkA7Ml_c6x2EvsOqT2ZZFd-9IxYjOypR8fGvW4DYglSDXSZy0TklWrKbFvb5d7GTaPPIlx7vSj1jaxKc2c7J26_Ry4_IUz6CpjIVUrtO-HH8l55/s1600/Windows7.jpg" title="Windows 7" /></a></div>
<div style="line-height: 1.5; text-align: justify;">
<br /></div>
<div style="line-height: 1.5; text-align: justify;">
The answer lies in <a href="http://en.wikipedia.org/wiki/Data_Execution_Prevention">DEP </a>(Data Execution Prevention). This feature was enabled in my Windows 7 machine. After I disable this feature I was able to run my plugin in Firefox. Here is how you can disable DEP in Windows 7.</div>
<div style="line-height: 1.5; text-align: justify;">
<br /></div>
<div style="line-height: 1.5; text-align: justify;">
1. Go to command prompt<br />
2. Execute the command <b>bcdedit /set nx AlwaysOff</b><br />
3. Reboot the machine (rebooting is required for the above setting to reflect)</div>
<div style="line-height: 1.5; text-align: justify;">
<br /></div>
<div style="line-height: 1.5; text-align: justify;">
Ideally with DEP enabled, if you want to run your plugin, you have to build the plugin with the latest version of Windows SDK.</div>
<div style="line-height: 1.5; text-align: justify;">
<br /></div>
<div style="line-height: 1.5; text-align: justify;">
<br /></div>Raveesh Kumarhttp://www.blogger.com/profile/02898028390727186228noreply@blogger.com0tag:blogger.com,1999:blog-8615869372543931037.post-7957935463105263372011-06-17T08:16:00.000-07:002011-06-17T09:15:39.281-07:00How to make your old plugins work with Firefox 4?<div style="TEXT-ALIGN: justify; LINE-HEIGHT: 1.5">I had a old plugin, which was working fine with Firefox 3.6. When I upgraded to Firefox 4.0.1, it suddenly stopped working. Firefox was listing it in the list of plugins installed and pointing to the right dll to load. Googling for this issue did not help. Also, tried replicating the registry entries similar to the ones in the machine which had Firefox 3.6 installed. No, it also did not work out.<br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXb87La_YEzZGoHpJzzjahgCYfGzdXEVQur_yvtZk5cReMQnR7JqfHxl34ANpIxIDFe6VdFdbgomRJ3AnPdyxTYr5ZYpoMEnPfIjTFgsUnU4SVcbp4lJysUPC_qOzo5GskQf6z8Ntc-Cft/s1600/logo-wordmark-version-4.png"><img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 320px; DISPLAY: block; HEIGHT: 90px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5619221567976994402" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXb87La_YEzZGoHpJzzjahgCYfGzdXEVQur_yvtZk5cReMQnR7JqfHxl34ANpIxIDFe6VdFdbgomRJ3AnPdyxTYr5ZYpoMEnPfIjTFgsUnU4SVcbp4lJysUPC_qOzo5GskQf6z8Ntc-Cft/s320/logo-wordmark-version-4.png" /></a>From <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653">Process Explorer</a>, came to know that Firefox 4.0.1 was not at all loading the dll. Then I looked into the Firefox logs to see what exactly is going on with this plugin dll.<br />[ Use the following commands to get the Firefox browser logs in file c:\plugins.log.<br />C:\> set NSPR_LOG_MODULES=all:5<br />C:\> set NSPR_LOG_FILE=c:\plugins.log<br />C:\> cd C:\Program Files\Mozilla Firefox<br />C:\> firefox.exe ]<br /><br />To my surprise, Firefox was actually loading the plugin dll. But immediately it was unloading it. Then I put debug logs in all the plugin implemented APIs, to see what was going wrong. Finally found out that in <em>NPP_Initialize()</em>, I was calling <em>NS_GetServiceManager()</em>, an <a href="https://developer.mozilla.org/en/xpcom_api_reference">XPCOM API</a> to get a reference to the XPCOM service manager. It was failing to get the reference and <em>NPP_Initialize()</em> was returning <em>NPERR_GENERIC_ERROR</em> to the browser. Cause of the issue is thus found out. Looking for solutions in Google again, I hit on the <a href="http://www.codeproject.com/KB/miscctrl/XPCOM_Creation.aspx?display=Mobile">code project link</a>, which explained two ways of getting the reference for XPCOM service manager. One, I was using in my plugin using the XPCOM API, <em><a href="https://developer.mozilla.org/en/NS_GetServiceManager">NS_GetServiceManager()</a></em>. The other one used the XPCOM API <em><a href="https://developer.mozilla.org/en/NS_InitXPCOM2">NS_InitXPCOM2()</a></em>. Tried this one. Wow, it worked!<br /><br />You can surely try this solution, if you are looking for solutions as to why your old plugin is not working in Firefox 4.0.1. See you then. Happy debugging!</div>Raveesh Kumarhttp://www.blogger.com/profile/02898028390727186228noreply@blogger.com0tag:blogger.com,1999:blog-8615869372543931037.post-22306468493761087882010-03-28T10:16:00.000-07:002010-03-28T10:33:17.897-07:00Finding Out Slider Count and Total Call Time in Sony Ericsson Mobile Phone<div style="line-height: 1.5; text-align: justify;">Have you ever wanted to find out, how many times you have slided your Sony Ericsson slider phone(or slider count)? or Total call time of your Sony Ericsson mobile? Well, you find that out and more, with few key presses in your mobile.<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfb1Ss53kl96Y1NpwPW4WKoOcosCCXh8t7bRbEMeNlvNa2gfMB0Azhrpw2gXX0htDAs_jLqYh2DLbfvRWA5EM9PFL3ogBmhTSH4SPWnnswyUJK6ebLATTGs5Zx5tCfAboBn0wtMbd5LCwY/s1600/W995a-main.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 184px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfb1Ss53kl96Y1NpwPW4WKoOcosCCXh8t7bRbEMeNlvNa2gfMB0Azhrpw2gXX0htDAs_jLqYh2DLbfvRWA5EM9PFL3ogBmhTSH4SPWnnswyUJK6ebLATTGs5Zx5tCfAboBn0wtMbd5LCwY/s320/W995a-main.jpg" alt="" id="BLOGGER_PHOTO_ID_5453735590695031954" border="0" /></a><li><div style="line-height: 1.5; text-align: justify;">Press the keys in the following order in your Sony Ericssson mobile phone - Right Navigation Key + '*' key + Left Navigation Key + Left Navigation Key + '*' key + Left Navigation Key + '*' key.</div></li><li>After you press the above keys, Service menu comes up on the mobile screen.</li><li>For finding out the slider count, Go to Service Info -> Slider Count.</li><li>For finding out the total call time of the mobile, Go to Service Tests -> Total Call time.</li><li>Apart from these, you can find the Model Info, Software Info, Configuration Info from 'Service info' menu item. You can also run tests to see the working of Main Display, LED/Illumination, Keys, Speaker, Earphone, Microphone, Vibrating Alert, Camera, Video Call Camera, Flash LED, FM Radio from 'Service tests' menu item.</li><li>To come out of Service menu, press the End Call key.</li>P.S: The above tests were done on Sony Ericsson W705 and W550i.</div>Raveesh Kumarhttp://www.blogger.com/profile/02898028390727186228noreply@blogger.com2tag:blogger.com,1999:blog-8615869372543931037.post-86795743259353900932010-03-24T09:58:00.000-07:002010-03-28T10:44:06.856-07:00What to do when you are unable to make outgoing calls from your Hutch/Vodafone SIM?<div style="line-height: 1.5; text-align: justify;">What is your immediate reaction when you are unable to make any calls from your cell phone. Frustrated? That was how I felt 2 days ago, when I was unable to make any outgoing calls from my mobile phone from a prime location in Bangalore. Electronic gadgets have made us over dependent on them nowadays.<br /><br />My initial reaction was to restart the cell phone. No, it did not work. Then I tried switching off the phone, removing the battery and SIM card, put them back again to see if it works. No, it also didn't work. After half an hour or so, when I tried to make a call, I was able to do so. But it was not because of the tasks I did above.<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEga9x_jJdeM-NcFvsJFIz4uUbrHlXspf9oedSxs7ySHanxuZCrdDjx9zhq4pjgV29PJnLZdIYQTYqAFIQeQouW9oL_XxsxfBSO-aoOcvUCOsZg-qtwq77xyByT8J2DnDwIe2j8XJpXT8aYR/s1600/W705_prod_topic_mediaspace_img.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 130px; height: 299px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEga9x_jJdeM-NcFvsJFIz4uUbrHlXspf9oedSxs7ySHanxuZCrdDjx9zhq4pjgV29PJnLZdIYQTYqAFIQeQouW9oL_XxsxfBSO-aoOcvUCOsZg-qtwq77xyByT8J2DnDwIe2j8XJpXT8aYR/s400/W705_prod_topic_mediaspace_img.png" alt="Sony Ericsson w705 cell phone" id="BLOGGER_PHOTO_ID_5452246903185353826" border="0" /></a>Later I came to know that though the network icon in the phone showed full coverage when I tried restarting the phone or removing the battery/SIM, it was not so. In such cases, updation of the SIM card will do the trick. I use Hutch/Vodafone connection.<br /><br />Following are the steps you might want to follow to resolve the issue.<br /><li>Go to Hutch Plus menu in your mobile phone.</li><li>Select Hutch Roam.</li><li>Select Hutch.</li><li>A Message will be displayed - 'SIM card update starts...', Select OK</li><li>One more message will be displayed - 'Allow SIM Update? Phone will restart', Select OK</li><li>After you do this you will see, 'Inactive SIM', in place of operator logo Hutch.</li><li>Phone will restart after few seconds and network coverage icon is shown on your cell phone.</li>You should now be able to make outgoing calls.<br />P.S: The above procedure has been tested only on Home network of Hutch and not in Hutch Roaming.<br /></div>Raveesh Kumarhttp://www.blogger.com/profile/02898028390727186228noreply@blogger.com3tag:blogger.com,1999:blog-8615869372543931037.post-54235963313140854182010-03-21T06:46:00.001-07:002010-03-21T06:56:19.120-07:00BSNL EVDO Data card availability only on paper!<div style="line-height: 1.5; text-align: justify;">If you had noticed the ads by BSNL in newspapers, featuring ever smiling Deepika Padukone and Abhinav Bindra, about the EVDO Data Cards they are offering now for discounted prices, you tend to believe that the EVDO Data cards are readily available. As per the ad, for customers activating the EVDO postpaid unlimited data plan till 31st March 2010, fixed monthly rental will be Rs.750 instead of Rs.999. Though there are intial charges like Activation Charges(Rs.500), price of Data Card(Rs.3500)/monthly rental for the card(Rs.200) and refundable security deposit(Rs.1000), it seemed like a good bet. But when you do a reality check by contacting the BSNL Customer Service Center, the story is entirely different.<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjj4rMCoWdC_vHi4s0ddJSaVIkKc2xNlmgtmLvTz68ZbfsGBo05i2vFznOJSk4vOKV-4XFtMe51_NgfXEfnkfs6IIgyRLY5G3F2aSvBLgZNKPA6LXzWZDB3L9iqs9F7LwRZqj-CCYkpXA1/s1600-h/BSNL_Evdo_card_Ad.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 319px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjj4rMCoWdC_vHi4s0ddJSaVIkKc2xNlmgtmLvTz68ZbfsGBo05i2vFznOJSk4vOKV-4XFtMe51_NgfXEfnkfs6IIgyRLY5G3F2aSvBLgZNKPA6LXzWZDB3L9iqs9F7LwRZqj-CCYkpXA1/s400/BSNL_Evdo_card_Ad.jpg" alt="Deepika Padukone and Abhinav Bindra in BSNL EVDO Card Ad" id="BLOGGER_PHOTO_ID_5451083585308727650" border="0" /></a>When I contacted the Executive at BSNL Customer Service Center at Vijayanagar, Bangalore, he said there are no EVDO Data cards available as of now. Though the ads are in place, they say they have not been supplied enough EVDO Data Cards. Instead he offers me a NIC(Network Interface card), with max speed upto 144 kbps. Well, why do I go for that, when my BSNL Broadband connection(Dataone) offers much more than that speed(256 kbps). He adds that though the max speed is 144 kbps, NIC average speed may be upto 100 kbps. Then, when I tell the area where I reside, he reduces average speed further. BSNL NIC Card uses CDMA 1x technology, predecessor of CDMA 1x EVDO, offers speed upto 144 kbps whereas BSNL EVDO Card offers upto 3.1 Mbps. BSNL Customer Service executive also informed that the average speed offered by EVDO Card can be upto 1 Mbps. Voila, who would not want such a speed on a wireless internet card!<br /><br />Well, my main intention was to get EVDO Data Card which offers higher speed than the BSNL broadband. More importantly, I am fed up with the frequent connection lost scenarios with BSNL Broadband. Also, pricewise current discount matches with the unlimited usage offer by BSNL Broadband Dataone connection, I am currently having for Rs.750. Hoping for the things to improve at BSNL.<br /><br />For FAQs on NIC and EVDO Cards by BSNL, you can visit this <a href="http://www.bsnl.co.in/faq/faqans.php?fstring=&fcategory=EVDO&submit=Go#top">BSNL link</a> and for the tariff plans, click <a href="http://www.bsnl.co.in/service/internet_on_cdma.htm">here</a>.</div>Raveesh Kumarhttp://www.blogger.com/profile/02898028390727186228noreply@blogger.com1tag:blogger.com,1999:blog-8615869372543931037.post-15105389569269192362010-03-19T11:16:00.000-07:002010-03-19T11:32:40.016-07:00Web Services On Devices : WS Discovery using Function Discovery in Windows Vista<div style="line-height: 1.5; text-align: justify;"><span style="font-weight: bold;">Function Discovery APIs for performing WS Discovery:<br /></span>Function Discovery APIs in Windows Vista, provides a uniform programmatic interface for enumerating system resources, such as hardware devices, whether they are local or connected through a network. It enables applications to discover and manage lists of devices or objects sorted by functionality or class. Function Discovery supports an extensible discovery provider model. The providers included in the system provide an abstraction layer over existing standards such as Plug and Play (PnP), SSDP, WS-Discovery, and the registry. To find more about Function Discovery visit the following links:<br />Function Discovery - <a href="http://msdn.microsoft.com/en-us/library/aa814070.aspx">http://msdn.microsoft.com/en-us/library/aa814070.aspx<br /></a>Retrieving all function instances in a Category - <a href="http://msdn.microsoft.com/en-us/library/aa364810%28VS.85%29.aspx">http://msdn.microsoft.com/en-us/library/aa364810(VS.85).aspx</a><br /><br /><span style="font-weight: bold;">WS-Discovery:</span><br />Windows SDK 6.1 comes with a sample program demonstrating the use of Function Discovery API. The sample can be found in the following path - “windows SDK folder\Samples\NetDs\FunctionDiscovery”. This sample program discovers PnP devices on the network.<br /><br /><span style="font-weight: bold;">Modifying the Sample Program to discover WSD devices on the network: </span><br /><span style="font-weight: bold;">CMyFDHelper class :</span> <span style="font-style: italic;">CMyFDHelper</span> (in <span style="font-style: italic;">FunctionDiscovery.h</span>) is a helper class and is derived from <span style="font-style: italic;">CfunctionDiscoveryNotificationWrapper.</span> <span style="font-style: italic;">CMyFDHelper</span> class implements <span style="font-style: italic;">OnUpdate, OnError, OnEvent</span> callback functions of parent class – <span style="font-style: italic;">CfunctionDiscoveryNotificationWrapper</span>.<br /><br /><span style="font-weight: bold;">Create Instance Collection Query :</span> <span style="font-style: italic;">HRESULT CMyFDHelper::ListFunctionInstances( const WCHAR* pszCategory )</span> lists all the devices of <span style="font-style: italic;">pszCategory</span> found. Here, it creates an Instance Collection query by calling <span style="font-style: italic;">CreateInstanceCollectionQuery</span> of <span style="font-style: italic;">IFunctionDiscovery</span>. Pass first parameter <span style="font-style: italic;">pszCategory</span> as <span style="font-style: italic;">FCTN_CATEGORY_WSDISCOVERY</span>.<br /><br /><span style="font-weight: bold;">Add a constraint to Query :</span> <span style="font-style: italic;">IFunctionInstanceCollectionQuery *pQuery</span> is the query created. Add constraint to the query for searching only WSD printers.<br /><span style="font-style: italic;">hr = pQuery->AddQueryConstraint(</span><br /><span style="font-style: italic;"> PROVIDERWSD_QUERYCONSTRAINT_TYPE,</span><br /><span style="font-style: italic;"> L"http://schemas.microsoft.com/windows/2006/08/wdp/print/PrintDeviceType" ); </span><br />To find more about AddQueryConstraint go to - <a href="http://msdn.microsoft.com/en-us/library/aa364366%28VS.85%29.aspx">http://msdn.microsoft.com/en-us/library/aa364366(VS.85).aspx</a><br /><br /><span style="font-weight: bold;">Execute the Query and Count of instances: </span>This is done by calling execute function on pQuery. Since WSD Providers only return instances through the <span style="font-style: italic;">IFunctionDiscoveryNotification </span>interface, <span style="font-style: italic;">dwCount</span> in statement - <span style="font-style: italic;">pCollection->GetCount( &dwCount ); </span>will be zero. So, return from here.<br /><br /><span style="font-weight: bold;">IFunctionDiscoveryNotification interface :</span> In <span style="font-style: italic;">CMyFDHelper:: Initialize(), IFunctionDiscoveryNotification</span> interface Functions - <span style="font-style: italic;">OnUpdate, OnError, OnEvent</span> are implemented in <span style="font-style: italic;">CMyFDHelper</span>. So when the Function discovery APIs detect the presence of WSD devices in the network, <span style="font-style: italic;">OnUpdate </span>callback function in <span style="font-style: italic;">CMyFDHelper</span> class will be called.<br /><br /><span style="font-weight: bold;">In HRESULT CMyFDHelper::OnUpdate(),</span> there is a block of code which check what event has occurred(device added, removed or updated). In case of discovery of WSD printer, the event will be added(<span style="font-style: italic;">QUA_ADD == eAction</span>). So, in this case, call <span style="font-style: italic;">CMyFDHelper::DisplayProperties()</span>.<br /><br /><span style="font-weight: bold;">CMyFDHelper::DisplayProperties()</span> outputs all the properties of the particular device. There is a switch case block where there is case for <span style="font-style: italic;">VT_LPWSTR</span>. Check for <span style="font-style: italic;">pszKeyName </span>is <span style="font-style: italic;">PNPX_GlobalIdentity</span>. If it is so, extract the key value. Key value is <span style="font-style: italic;">UUID.</span> Store this value which will be later required for the creation of Device proxy.</div>Raveesh Kumarhttp://www.blogger.com/profile/02898028390727186228noreply@blogger.com2tag:blogger.com,1999:blog-8615869372543931037.post-66946808807240672312010-03-17T07:59:00.000-07:002010-03-19T11:31:48.354-07:00Web Services on Devices : Developing a Print Client in Windows Vista<div style="line-height: 1.5; text-align: justify;">With WSDAPIs generated in previous post, we can now start developing a Print client.<br /><br /><span style="font-weight: bold;">How do I start developing a Print Client?<br /></span>For the Print Client to communicate with a WSD Printer, first it has to discover the WSD Printers on the network. For knowing about discovering the Printers on the network and getting the UUID – universally unique identifier for the printer, refer to the sample Function Discovery program in the following path - "Folder where windows SDK is installed\Samples\NetDs\FunctionDiscovery".<br /><br /><span style="font-weight: bold;">Discovering the Printers on the network and getting the UUID :</span><li>Sample program defines <span style="font-style: italic;">CMyFDHelper</span> class which is used to discover PnP devices on the network. This can be tweaked to discover WSD Printers on the network.</li><li>Call <span style="font-style: italic;">HRESULT CoInitializeEx (LPVOID pvReserved, DWORD dwCoInit)</span> with <span style="font-style: italic;">pvReserved = NULL</span> and <span style="font-style: italic;">dwCoInit = COINIT_MULTITHREADED</span> from <span style="font-style: italic;">main()</span>; (Ref - <a href="http://msdn.microsoft.com/en-us/library/ms886306.aspx">http://msdn.microsoft.com/en-us/library/ms886306.aspx</a> ).This function initializes the Component Object Model (COM) for use by the current thread. Applications are required to use <span style="font-style: italic;">CoInitializeEx</span> before they make any other COM library calls except for memory allocation functions.</li><li>For the exact changes to be made in <span style="font-style: italic;">CMyFDHelper</span> class to discover WSD devices, please wait for my next <a href="http://techbaraha.blogspot.com/2010/03/ws-discovery-using-function-discovery.html">post on WS Discovery</a>.</li><li>Call <span style="font-style: italic;">::CoUninitialize();</span></li><span style="font-style: italic;"><br /></span><span style="font-weight: bold;">Creating Service Proxy and sending messages to the server:</span>(Refer to the File Service example in Windows SDK folder, mentioned earlier)<li>Create a UUID for client by calling <span style="font-style: italic;">UuidCreate()</span> function. Convert the obtained UUID to string format.</li><li>Create a Service proxy by calling <span style="font-style: italic;">CreateCPrinterServiceTypeProxy(LPCWSTR pszDeviceAddress, LPCWSTR pszLocalAddress, CPrinterServiceTypeProxy** ppProxyOut, IWSDXMLContext** ppContextOut)</span> [defined in PrinterServiceTypeProxy.cpp, LPCWSTR is wchar*] passing UUIDs of device/server and client in <span style="font-style: italic;">pszDeviceAddress</span> and <span style="font-style: italic;">pszLocalAddress</span> respectively.This function returns <span style="font-style: italic;">CPrinterServiceTypeProxy</span> which will be used for calling methods on the server. Client calls <span style="font-style: italic;">CPrinterServiceTypeProxy</span> methods(like <span style="font-style: italic;">CreatePrintJob, SendDocument</span> etc), which have the same interface that of server and they send the commands to the server. Note: We need to create <span style="font-style: italic;">IWSDDeviceProxy</span> before creating any <span style="font-style: italic;">IWSDServiceProxy</span>(<span style="font-style: italic;">CPrinterServiceTypeProxy</span> is of this type and a single device can host multiple services). Creation of device proxy before service proxy is handled at <span style="font-style: italic;">CreateCPrinterServiceTypeProxy</span>. [More details on device and service proxies can be found from the following link - <a href="http://blogs.msdn.com/dandris/archive/2008/03/03/wsdapi-101-part-4-the-interfaces-under-the-generated-code.aspx">http://blogs.msdn.com/dandris/archive/2008/03/03/wsdapi-101-part-4-the-interfaces-under-the-generated-code.aspx</a> ]</li><li>Create a Event Sink class for Server events. Define a class named <span style="font-style: italic;">CPrinterServiceTypeEventNotify</span> derived from <span><span style="font-style: italic;">IPrinterServiceTypeEventNotify</span>. Implement the <span style="font-style: italic;">IPrinterServiceTypeEventNotify</span></span> methods defined as virtual, in this class – <span style="font-style: italic;">PrinterElementsChangeEvent, JobStatusEvent, JobEndStateEvent</span>. These are call back functions which will be invoked when the server sends respective events. We can update our structures holding printer, job info in these functions.</li><li>Functions defined above will be called if the client is subscribed to the events from server. Call the subscribe functions like <span style="font-style: italic;">SubscribeToJobStatusEvent</span>, <span style="font-style: italic;">SubscribeToJobEndStateEvent</span> on service proxy i.e <span style="font-style: italic;">CPrinterServiceTypeProxy</span> object.(these functions are defined in <span style="font-style: italic;">PrinterServiceTypeProxy.cpp</span>)</li><li>Call the server functions on <span style="font-style: italic;">CPrinterServiceTypeProxy</span> object. For example, for <span style="font-style: italic;">CreatePrintJob</span> you need to send filled <span style="font-style: italic;">CREATE_PRINT_JOB_REQUEST_TYPE</span> structure and <span style="font-style: italic;">CREATE_PRINT_JOB_RESPONSE_TYPE*</span> for response. Type definitions for the same can be found in <span style="font-style: italic;">PrinterServiceTypeTypes.h</span></li><span style="font-weight: bold;"><br />Resolving the Build Errors in Visual Studio:</span><li>Set the project dependencies and build order – Right click on project. Select Project Dependencies. Make sure Client project depends on the project created for Print Schema. Also set the build order as Print Schema project, Client project in the same window opened.</li><li>You may get compilation error for not able to find header files like <span style="font-style: italic;">PrinterServiceTypeProxy.h</span>. Then check whether you have included the files from project for PrinterServiceSchema. To include them, right click on Projects. Select Properties -> Configuration Properties -> C/C++ -> General -> Additional Include directories and type project directory for PrinterServiceSchema.</li><li>You may get linker error (unresolved external symbol) for <span style="font-style: italic;">UuidCreate()</span>. If so, check whether you have included <span style="font-style: italic;">rpcrt4.lib</span>. To include the same, right click on Project. Select Properties -> Configuration Properties -> Linker -> Command line -> Additional options. Type <span style="font-style: italic;">rpcrt4.lib</span>.</li><li>If you get linker errors for wsdapi functions make sure you have included <span style="font-style: italic;">wsdapi.lib</span>.</li>With the above steps, you are now ready with the basic Print Client which communicates with the WSD Printer.</div>Raveesh Kumarhttp://www.blogger.com/profile/02898028390727186228noreply@blogger.com0tag:blogger.com,1999:blog-8615869372543931037.post-62542665566438054892010-03-16T05:45:00.000-07:002010-03-16T06:12:55.731-07:00Web Services On Devices : Getting WSDAPIs for Print Client<div style="line-height: 1.5; text-align: justify;">WSDAPI stack provided by Microsoft as part of Windows Rally technologies, is an implementation of <a href="http://en.wikipedia.org/wiki/Devices_Profile_for_Web_Services">DPWS(Devices Profile for Web Services)</a>, which defines a minimal set of implementation constraints to enable secure Web Service messaging, discovery, description, and eventing on resource-constrained devices.<br /><br />If you had gone through the links, I provided in my first post on Web Services on Devices (<a href="http://techbaraha.blogspot.com/2010/03/web-services-on-devices-set-up.html">Web Services on Devices : Environment Set Up in Windows Vista</a>), you would have known by now, what it requires to develop a Web Service Device which hosts Web Service and a Web Service Client, which uses the services hosted on Web Service Device. In this post, I will be explaining how you can develop a Web Services client in Microsoft Windows Vista, using WSDAPIs taking the example of Print Service.<br /><br /><span style="font-weight: bold;">Where can I get more information on DPWS, WSDAPIs, Windows Rally Technologies?</span><br />Go to - <a href="http://www.microsoft.com/whdc/connect/rally/rallywsd.mspx">http://www.microsoft.com/whdc/connect/rally/rallywsd.mspx</a><br /><span style="font-weight: bold;"><br />Where can I get the Print Device and Print Service Specifications for implementing Print Service and Print Service Client?</span><br />Go to - <a href="http://www.microsoft.com/whdc/connect/rally/wsdspecs.mspx">http://www.microsoft.com/whdc/connect/rally/wsdspecs.mspx</a>, where you can download Specifications and Supporting Files for Print Device and Print Service. These schemas/specification describe the format of data being exchanged between the Web Service and Web Service Client and the interfaces which need to implemented by the Device, which provides the Print Service. After unzipping the zip file downloaded from the above link, you will find WSDPrinterService.wsdl, supporting .xsd files and WSDPrintService.doc explaining the schema. WSDPrintService.doc should give you a fair idea of what it requires to develop a Print Client based on WSD protocol.<br /><br /><span style="font-weight: bold;">Developing a Print Service Client, using the schema/specification just downloaded:</span><br /><span style="font-weight: bold;"><br />How do I get WSDAPIs to be called from Print Client?</span><br />Following steps explain how to go about building Print Client.<br /><li><span style="font-style:italic;">Get WSDPrinterService.wsdl and other .xsd files(Print Service Schema).</span></li><li><span style="font-style:italic;">Generate a config file by running WsdCodeGen on WSDPrinterService.wsdl.</span><br />You can find wsdcodegen.exe in "Windows SDK folder\Bin". run "wsdcodegen.exe /generateconfig:all WSDPrinterService.wsdl". This command will generate codegen.config. Make sure the directory which contains WSDPrinterService.wsdl also holds all the .xsd files from Print Service Schema as WSDPrinterService.wsdl includes those .xsd files. Otherwise, you will find that message structure elements in PrinterServiceTypeTypes.h (which gets generated in next step) will be empty.</li><li><span style="font-style:italic;">Generate IDL, C++ and header files.</span><br />run "wsdcodegen.exe /generatecode codegen.config". This command will generate the following files - PrinterServiceType.idl, PrinterServiceTypeProxy.h, PrinterServiceTypeProxy.cpp, PrinterServiceTypeTypes.h, PrinterServiceTypeTypes.cpp and PrinterServiceTypeStub.cpp. These files can be added as a part of Visual Studio project and can be built into a static library (.lib)</li><li>You may face problems like – not able to include PrinterServiceType.h in building the above .lib, since PrinterServiceTypeProxy includes PrinterServiceType.h, which contains the definitions for interfaces like CreatePrintJob, SendDocument etc. This and other files – PrinterServiceType_p.c and PrinterServiceType_i.c are generated by MIDL (Microsoft Interface Definition Language) compiler when building the above mentioned .lib. You may notice that, in case of above error, MIDL would have generated PrinterServiceType_h.h in the Project folder. To make sure that MIDL generates PrinterServiceType.h make the following settings changes. In Visual Studio solution explorer, right click on the Project. Select Properties, Configuration Properties, MIDL, Output, Header File. Change the value to $(InputName).h instead of $(InputName)_h.h</li><br />Now you are ready with required WSDAPIs to be called from your Print Client application.</div>Raveesh Kumarhttp://www.blogger.com/profile/02898028390727186228noreply@blogger.com0tag:blogger.com,1999:blog-8615869372543931037.post-52469627228929205242010-03-15T09:19:00.001-07:002010-03-15T09:50:37.966-07:00Web Services on Devices : Environment Set Up in Windows Vista<div style="LINE-HEIGHT: 1.5; TEXT-ALIGN: justify">Web Services on Devices(WSD) is still a new technology as the amount of literature available on the web on developing WSD applications is limited. Here, I am presenting a series of posts, which may help those who are new to WSD.<br /><br />Microsoft provides set of WSD APIs for developing WSD Applications from Windows Vista onwards. Here are some FAQs while setting up environment in Vista for WSD Development.<br /><br /><span style="font-weight:bold;">Setting up Windows SDK and Visual Studio environment for developing Web Services on Devices Applications:-</span><br />Best way to set up the required environment is to first install Visual Studio and then Windows SDK. This will avoid the getting into unnecessary problems relating to integrating Windows SDK directory paths to Visual Studio.<br />Please Note : When I started using WSDAPIs for developing WSD Applications, I had used Windows SDK 6.1 and Microsoft Visual Studio 2008. So, the information provided here pertain to these softwares.<br /><br /><span style="font-weight:bold;">What if I have already installed Windows SDK and now installing Visual Studio?<br /></span>Once the Visual Studio installation is complete, follow the instructions in the following Microsoft Windows SDK blog, where you need to use Windows SDK Configuration tool to integrate with the Visual Studio. <a href="http://blogs.msdn.com/windowssdk/archive/2008/03/01/integrating-windows-sdk-and-vs-with-new-sdk-configuration-tool.aspx">http://blogs.msdn.com/windowssdk/archive/2008/03/01/integrating-windows-sdk-and-vs-with-new-sdk-configuration-tool.aspx</a>. Make sure you choose the latest version of Windows SDK from configuration tool, in this case 6.1, if you also have older versions of Windows SDK installed.<br /><br /><span style="font-weight:bold;">How to validate whether Visual Studio directories were successfully updated with Windows SDK?<br /></span>Go to Start, Programs, Microsoft Visual Studio 2008, Visual Studio Tools, Visual Studio 2008 Command Prompt. At the command prompt, type PATH. Check the following path is listed, "dir where Latest Windows SDK was installed\bin"<br /><br /><span style="font-weight:bold;">Where do I start reading about WSDAPIs?</span><br />You can refer to the following blog link by Dan Driscol, a Microsoft developer. <a href="http://blogs.msdn.com/dandris/archive/2007/11/09/wsdapi-101-part-1-web-services-from-10-000-feet.aspx">http://blogs.msdn.com/dandris/archive/2007/11/09/wsdapi-101-part-1-web-services-from-10-000-feet.aspx</a>. In case of any doubt, you can drop a comment in his blog post. Usually replies within a day or two.<br /> <br /><span style="font-weight:bold;">Where can I find sample programs on WSDAPIs in windows SDK?</span><br />Go to "Folder where windows SDK is installed\Samples\Web\WSDAPI". Here you will find 2 folders: Stock Quote and File Service. Stock Quote is a simple example where Client is calling a method on Service. File Service is more complete example which covers WS Eventing as well. Both examples have code for Client and Service and require Client to know the device address/UUID.<br /><br /><span style="font-weight:bold;">Ok, where can I find a sample program where a Client discovers WSD devices on the network?</span><br />Go to "Folder where windows SDK is installed\Samples\NetDs\FunctionDiscovery". This sample program discovers PnP devices on the network. This code can be easily modified to find WSD devices on the network. <br /></div>Raveesh Kumarhttp://www.blogger.com/profile/02898028390727186228noreply@blogger.com0