Showing posts with label Interop\PInvoke. Show all posts
Showing posts with label Interop\PInvoke. Show all posts

April 04, 2007

Q/A with Mkaif - Java .NET interoperability

Here are some Q/A with Mohammad Akif, Senior Architect MS.You can find his blog at -

 http://blogs.msdn.com/mohammadakif


Question: Where do you see Java & .NET in the future? will we only see .NET?
Answer: I wish :-), although .NET continue to grow rapidly, I believe that for the next few ears at least we will see both Java and .NET. I do strongly believe that Java cannot survive in its current form and less complex manifestations (ruby on rails etc.) would replace it, some of the simpler to use forms will surrive longer than e.g. EJBs and swing which seem to be on a decline


Question: Is WSE built into WCF, or do I need both?
Answer: WCF is a unified programming model for other MS models like WSE, Systems.messaging, enterprise services and others


Question: Where can I find information about project Tango
Answer: Please refer to "Microsoft at JavaOne" section of my blog at http://blogs.msdn.com/mohammadakif


Question: Where can I find your 'Implementing a hybrid SOA in your enterprise' deck that you plan to present at JavaOne
Answer: I will make it available (or provide a link to it) on my blog after the JavaOne conference in May


Question: How much WCF supports interoperability as against Web Service? Or what extra features WCF provides for Interoperability than asmx web service
Answer: WCF allows you to do everything that ASMX allows plus more, in terms of allowing you to have a standardized programming model


Question: What is the name of the book you mentioned and where can I find it
Answer: It is called 'WCF, step by step' by MS Press, I have posted the link on my blog under 'Vista , .NET resources'


Question: Is WCF the only recommended way to implement interoperability?
Answer: Absolutely not, it is one of the many ways, WCF would take away some of the infrastructure plumbing but is not the right solution (or the recommended solution) in every scenario. We continue to support all the models that I mentioned during my presentation


Question: But "standardized programming model" supported by others too specifically while doing interoperability with other technologies?
Answer: Its 'standardized' in the MS world, plus we are working with a number of vendors to provide additional support, e.g. with Sun micrososystems we are working to test that WCF services can be consumed by them and are engaged in similar initiatives with other vendors.

March 18, 2007

CLR and Interop

The CLR allows seamless interactions between Microsoft .NET applications and COM. But how, exactly? The CLR team has posted an article here....

January 15, 2007

Blogs on Interop

This is cool blog on Interop with various other technologies....
All About Interop
http://blogs.msdn.com/dotnetinterop/

This is another one....
http://blogs.tedneward.com

December 15, 2006

WebSphere MQ Version 6 and Web Services

IBM Redbooks WebSphere MQ Version 6 and Web Services: "This IBM Redbook illustrates how to integrate WebSphere MQ technology in a Web Services environment. This book provides information about and examples pertaining to this topic, including the fundamental concepts, the technology, and the advanced programming features to help you succeed in your projects.

Web Services are fast becoming the platform for application integration. In fact, they are being referred to as the fundamental building blocks of Service-Oriented Architectures. Web Services expedite the move to distributed computing on the Internet or between businesses.

WebSphere MQ, the key component of IBM's Enterprise Service Bus, ensures single and reliable message delivery.

Multiplatform support enables application integration on heterogeneous networks. WebSphere MQ's application programming interface, features, and adaptors include support for transactional request/reply, tiered, and publish/subscribe application models.

The use of WebSphere MQ as a transport mechanism for Web Services is enabled by the support for Apache Axis and Microsoft .NET SOAP infrastructure in WebSphere MQ V6."

September 11, 2006

IBM WebSphere and Microsoft .NET Interoperability

IBM Redbooks IBM WebSphere and Microsoft .NET Interoperability: "This IBM Redbook explores interoperability design between applications running on IBM WebSphere and Microsoft's .NET platforms at the component level and using Web Services technologies. It is a good source of information for IT architects, IT specialists, application integrators and developers who have to design and develop interoperability solutions.

Part 1, 'Introduction', provides an overview of application interoperability starting with the business and technology drivers and introduces the concept of the Application Interoperability Stack, which defines a structured approach for application interoperability considerations and design.

Part 2, 'Component interoperability', provides an overview for component level interoperability and considerations to help with component interoperability solution design. A sample scenario shows interoperability between the WebSphere Java service component and .NET Windows Forms application.

Part 3, 'Web Services interoperability', introduces application interoperability implementation using Web Services technologies. It includes considerations to aid solution design and a sample scenario implementation showing WebSphere to .NET interoperability using Web Services technologies."

July 17, 2006

Some Technical Terms (Mostly Web / Service related)

Here are some technical terms mostly related to web or web service.

BPEL
Business Process Execution Language (or BPEL, pronounced 'bipple', or 'bee-pell'), is a business process modeling language that is executable. BPEL is an Orchestration language.
Origins of BPEL can be traced to WSFL and XLANG. It is serialized in XML and aims to enable programming in the large.

WSFL
Web Services Flow Language (WSFL) is an XML language proposed by IBM to describe the composition of Web services. WSFL has been superseded by BPEL.

XLang
XLang is an extension of the WSDL such that "an XLANG service description is a WSDL service description with an extension element that describes the behavior of the service as a part of a business process"

POX
Plain Old XML (POX) is a term used to describe basic XML, sometimes mixed in with other, blendable specifications like XML Namespaces, Dublin Core, XInclude and XLink. People typically use the term as a contrast with complicated, multilayered XML specifications like those for Web Services or RDF.

Workflow
Workflow at its simplest is the movement of documents and/or tasks through a work process. More specifically, workflow is the operational aspect of a work procedure: how tasks are structured, who performs them, what their relative order is, how they are synchronized, how information flows to support the tasks (wordflow) and how tasks are being tracked.

RSS
RSS(Really Simple Syndication) is a family of web feed formats used to publish frequently updated digital content, such as blogs, news feeds or podcasts.

XPDL
The XML Process Definition Language (XPDL) is a format standardized by the Workflow Management Coalition to interchange Business Process definitions between different workflow products like modeling tools and workflow engines. XPDL defines a XML schema for specifying the declarative part of workflow.
XPDL is designed to exchange the process design, both the graphics and the semantics of a workflow business process. XPDL contains elements to hold the X and Y position of the activity nodes as well as the coordinates of points along the lines that link those nodes. This distinguishes XPDL from BPEL which is also a process definition format, but BPEL focuses exclusively on the executable aspects of the process. BPEL does not contain elements to represent the graphical aspects of a process diagram.

REST
REST (representational state transfer) is an approach for getting information content from a Web site by reading a designated Web page that contains an XML (Extensible Markup Language) file that describes and includes the desired content. For example, REST could be used by an online publisher to make syndicated content available. Periodically, the publisher would prepare and activate a Web page that included content and XML statements that described the content. Subscribers would need only to know the URL (Uniform Resource Locator) for the page where the XML file was located, read it with a Web browser, interpret the content data using the XML information, and reformat and use it appropriately (perhaps in some form of online publication).

POX is different from
REST in that the latter refers to a style for communication protocols, while the former only refers to an information format style. REST could be seen as POX over HTTP with some peculiarities.

Web2.0
Web 2.0, a phrase coined by O'Reilly Media in 2004, refers to a perceived second-generation of Web-based services—such as social networking sites, wikis, communication tools, and folksonomies—that emphasize online collaboration and sharing among users. O'Reilly Media used the phrase as a title for a series of conferences, and it has since become widely adopted.

SAAS
Software as a service (SaaS) is a model of software delivery where the software company provides maintenance, daily technical operation, and support for the software provided to their client. SaaS is a model of software delivery rather than a market segment; it assumes the software is delivered over the internet. Software can be delivered using this method to any market segment, from home consumers to corporations.

JSON
JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language

ATOM
The name
Atom applies to a pair of related standards. The Atom Syndication Format is an XML language used for web feeds, while the Atom Publishing Protocol (APP for short) is a simple HTTP-based protocol for creating and updating Web resources.

XINS
XML Interface for Network Services (XINS) is an open source technology for definition and implementation of internet applications, which enforces a specification-oriented approach.

WSCL
The Web Service Conversation Language (WSCL) proposal defines the overall input and output message sequences for one web service using a finite state automaton FSA over the alphabet of message types.

XML-RPC
XML-RPC is a remote procedure call protocol which uses XML to encode its calls and HTTP as a transport mechanism. It is a very simple protocol, defining only a handful of data types and commands, and the entire description can be printed on two pages of paper. This is in stark contrast to most RPC systems, where the standards documents often run into the thousands of pages and require considerable software support in order to be used.

WS-MetadataExchange
One of many Web Service specifications,
WS-MetadataExchange deals with the exchange of information about a Web Service. It is a protocol used by a web service to describe itself.

WSML
The
Web Service Modeling Language WSML is a language for the specification of ontologies and different aspects of Web services. In this respect WSML provides a syntax and semantics for the Web Service Modeling Ontology WSMO. WSML uses well-known logical formalisms in order to enable the description of various aspects related to Semantic Web Services.

WSMX
WSMX (Web Service Modelling eXecution environment) is the reference implementation of WSMO (Web Service Modelling Ontology). It is an execution environment for business application integration where enhanced web services are integrated for various business applications. The aim is to increase business processes automation in a very flexible manner while providing scalable integration solutions.

April 07, 2006

Passing LogFont struct from VB to C#

LogFont structre in VB looks as:

Type LogFont ' 60 Bytes
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName As String * 32
End Type


Use CopyMemory API to convert struct in bytes

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)

Dim lf As LogFont
Dim bt(100) As Byte
CopyMemory bt(0), lf, LenB(lf)

'Finally call the C# function
objNet.SendLogFont(bt))

In C# you can convert bytes back to logFont as shown:

LogFont struct in C# looks as:


[StructLayout(LayoutKind.Sequential, Pack = 1)] //, CharSet = CharSet.Auto)]
internal struct LOGFONT
{
public const int LF_FACESIZE = 32;
public int lfHeight;
public int lfWidth;
public int lfEscapement;
public int lfOrientation;
public int lfWeight;
public byte lfItalic;
public byte lfUnderline;
public byte lfStrikeOut;
public byte lfCharSet;
public byte lfOutPrecision;
public byte lfClipPrecision;
public byte lfQuality;
public byte lfPitchAndFamily;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = LF_FACESIZE)]
public string lfFaceName;
}

Then write SendLogFont() function as

public void SendLogFont()
{
LOGFONT lf = new LOGFONT();
try
{
GCHandle gcHandle = GCHandle.Alloc(Buff, GCHandleType.Pinned);
// Marshals data from an unmanaged block of memory
// to a newly allocated managed object of the specified type.
Object Obj = Marshal.PtrToStructure(gcHandle.AddrOfPinnedObject(), typeof(LOGFONT));
lf = (LOGFONT)Obj;
// Free GChandle to avoid memory leaks
gcHandle.Free();
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}

}

April 05, 2006

Two common attribute mistakes while using the .NET interop


1. ClassInterface attributes

To expose .NET Assembly in COM create a public interface by using methods and properties that you want to expose in the TLB file, and then implement the interface in the class.

Make sure to have [ClassInterface(ClassInterfaceType.None)] before your class so that IntelliSense Features appears in COM.

E.g.
[ClassInterface(ClassInterfaceType.None)]
public class MyTestClass : IMyInterface

2. ComVisible attribute

Setting ComVisible to false makes the types in this assembly not visible to COM components. If you need to access a type in this assembly from COM, set the ComVisible attribute to true on that type. By default it sets to false.

E.g.
[assembly: ComVisible(true)]

April 04, 2006

Passing Int Array from Unmanged to Managed code

Unmanaged VB6.0 Code to C#

Note that you have to pass array without index.

Dim lParms(9) As Long
objNetAsm.GetInfo lParms

Managed C# Code:

In managed C# the array is accessed by refrence.
public long GetInfo (ref Int32[] plParms)
{

// Note that long in VB is Int32 in C#
}

UnmanagedVB6.0 to C++:

// Note you have to pass 0th element
cppObj.GetInfo lParms(0)

Unmanaged C++
// Using array pointer
GetInfo (long * plParms)
{

}

Some more good info on "Default Marshaling for Arrays"
http://msdn2.microsoft.com/en-us/library/z6cfh6e6(VS.80).aspx

October 10, 2005

P/Invoke (Windows API reference)

Greatest site having Windows API reference for C#, VB.NET & VB6. I used this several times to add Windows API reference in C# code (P/Invoke).

September 25, 2005

WebSphere and .Net Interoperability Using Web Services

IBM Redbooks WebSphere and .Net Interoperability Using Web Services: "IBM and Microsoft are strong supporters of the Web Services Interoperability Organization’s (WS-I) efforts to make building solutions using software from different suppliers a reality. In this IBM Redbook, we take a practical look at building a solution with IBM WebSphere and Microsoft .Net components using Web services that are compliant with the WS-I organization’s Basic Profile.

This redbook is aimed at customers who want to know how far the reality of Web services has caught up with the hype; it is for customers who want a redbook to help them decide whether Web services are right for them now.

The book provides an introduction to SOAP, WSDL and the rest of the Web services concepts. It provides a review of the many Web service specifications. Which ones are most important to building a practical solution?

We use a scenario based on work IBM has been doing with the insurance industry to demonstrate how to design a service-based solution and then implement it using the latest programming tools from IBM and Microsoft.
Based on our experience, we identify areas where extra effort up front will be rewarded with an easier implementation. "

December 15, 2004

Lotus Domino and .NET Coexistence

IBM Redbooks Lotus Domino and .NET Coexistence: "This paper is provides information on Lotus Domino and .NET coexistence. It provides development scenarios where Lotus Domino is the service consumer and the .NET application is the service provider, and the other way around where Lotus Domino is the service provider and the .NET application is the service consumer. The technologies used for integration are Web services and the COM interface."

WebSphere and .NET Coexistence

No doubt this will be best book on WebSphere and .NET Coexistence :)

IBM Redbooks WebSphere and .NET Coexistence: "This IBM Redbook explores the different coexistence scenarios for the WebSphere and .NET platforms. This book is a good source of information for solution designers and developers, application integrators and developers who wish to integrate solutions on the WebSphere and .NET platforms.

Part 1, “Introduction” is a quick introduction to the J2EE (WebSphere) and .NET technologies. It also depicts a basic architectural model that can be used to represent both WebSphere applications and .NET applications.

Part 2, “Scenarios” identifies several potential technical scenarios for coexistence via point-to-point integration between applications deployed in the IBM WebSphere Application Server and applications deployed in the Microsoft .NET Framework. This part provides in-depth technical details on how to implement certain scenarios using today’s existing technologies.

Part 3, “Guidelines” provides general guidelines for solution developers. A list of supporting technologies can help with the solution implementation. The Quality of Service chapter is a collection of services available on both platforms.

The Appendixes go further by using other IBM technologies and describing two integration solutions between Lotus Domino and .NET applications."

May 15, 2004

WebSphere MQ Solutions in a Microsoft .NET Environment

IBM Redbooks WebSphere MQ Solutions in a Microsoft .NET Environment: "The importance of the .NET platform is growing. This IBM Redbook illustrates how to integrate WebSphere MQ technology in a .NET environment, specifically with Microsoft Windows, by providing samples and guidance about how this can be achieved. It demonstrates the use of WebSphere MQ technology in a Microsoft Windows platform and proves WebSphere MQ is well integrated with the .NET environment.

This redbook demonstrates the use of WebSphere MQ in a .NET Web Service in these ways:

WebSphere MQ is used as a transport mechanism for the invocation of the Web Service by modifying the SOAP protocol wrapper to utilize WebSphere MQ rather than HTTP.

WebSphere MQ is used as a middleware product in the implementation of a Web Service. For example, the Web Service sends an MQ message as a request to another application and when this application responds, the Web Service provides a response back to the .NET Web Service client. Some sample applications in, C#, J2EE and VB.NET also demonstrate this.

Finally, a discussion about transactions is included, which highlights how WebSphere MQ participates in a transaction managed by DTC, and also how WebSphere MQ implements and uses Windows security interfaces, such as Secure Sockets Layer (SSL), is covered."

May 10, 2004

Windows Data Types

This MSDN Page has info about all Windows data types - character, integer, Boolean, pointer, and handle. (Mostly used in C/C++ and need to be considered while using Interop or porting code to .NET)

February 23, 2003

Unmanaged model Vs Managed model

Comparision of Unmanaged model Managed model

FeatureUnmanaged modelManaged model
Coding modelInterface-basedObject-based
IdentityGUIDsStrong names
Error Handling MechanismHRESULTsExceptions
Type compatibilityBinary standardType standard
Type definitionType libraryMetadata
Type safetyUnsafeOptionally safe
VersioningImmutableResilient

December 11, 2002

Enterprise Interoperability .NET and J2EE

MSDN article on Enterprise Interoperability: .NET and J2EE

September 23, 2002

SOAP (Web service) using VB and ASP

Originally written on 9/23/2002

VB DLL code: (soapTest.vbp class- clsSOAP.cls)

Public Function getData(id As Long, name As String) As String

getData = id & " " & name & "!"

End Function


ASP Code: (Facade) (SoapTest1.asp)


< %@ LANGUAGE=VBScript %>
< % Option Explicit On Error Resume Next Response.ContentType = "text/xml" Dim SoapServer If Not Application("SoapTest1Initialized") Then Application.Lock If Not Application("SoapTest1Initialized") Then Dim WSDLFilePath Dim WSMLFilePath WSDLFilePath = Server.MapPath("SoapTest1.wsdl") WSMLFilePath = Server.MapPath("SoapTest1.wsml") Set SoapServer = Server.CreateObject("MSSOAP.SoapServer") If Err Then SendFault "Cannot create SoapServer object. " & Err.Description SoapServer.Init WSDLFilePath, WSMLFilePath If Err Then SendFault "SoapServer.Init failed. " & Err.Description Set Application("SoapTest1Server") = SoapServer Application("SoapTest1Initialized") = True End If Application.UnLock End If Set SoapServer = Application("SoapTest1Server") SoapServer.SoapInvoke Request, Response, "" If Err Then SendFault "SoapServer.SoapInvoke failed. " & Err.Description Sub SendFault(ByVal LogMessage) Dim Serializer On Error Resume Next ' "URI Query" logging must be enabled for AppendToLog to work Response.AppendToLog " SOAP ERROR: " & LogMessage Set Serializer = Server.CreateObject("MSSOAP.SoapSerializer") If Err Then Response.AppendToLog "Could not create SoapSerializer object. " & Err.Description Response.Status = "500 Internal Server Error" Else Serializer.Init Response If Err Then Response.AppendToLog "SoapSerializer.Init failed. " & Err.Description Response.Status = "500 Internal Server Error" Else Serializer.startEnvelope Serializer.startBody Serializer.startFault "Server", "The request could not be processed due to a problem in the server. Please contact the system admistrator. " & LogMessage Serializer.endFault Serializer.endBody Serializer.endEnvelope If Err Then Response.AppendToLog "SoapSerializer failed. " & Err.Description Response.Status = "500 Internal Server Error" End If End If End If Response.End End Sub %>


WSML Code: (SoapTest1.wsml) Replace # with <

#!-- Generated 09/23/02 by Microsoft SOAP Toolkit WSDL File Generator, Version 1.02.813.0 -->

#?xml version='1.0' encoding='UTF-8' ?>
#servicemapping name='SoapTest1'>
#service name='SoapTest1'>
#using PROGID='soapTest.clsSOAP' cachable='0' ID='clsSOAPObject' />
#port name='clsSOAPSoapPort'>
#operation name='getData'>
#execute uses='clsSOAPObject' method='getData' dispID='1610809344'>
#parameter callIndex='1' name='id' elementName='id' />
#parameter callIndex='2' name='name' elementName='name' />
#parameter callIndex='-1' name='retval' elementName='Result' />
#/execute>
#/operation>
#/port>
#/service>
#/servicemapping>


WSDL Code: (SoapTest1.wsdl) Replace # with <

#?xml version='1.0' encoding='UTF-8' ?>
#!-- Generated 09/23/02 by Microsoft SOAP Toolkit WSDL File Generator, Version 1.02.813.0 -->
#definitions name ='SoapTest1' targetNamespace = 'http://tempuri.org/wsdl/'
xmlns:wsdlns='http://tempuri.org/wsdl/'
xmlns:typens='http://tempuri.org/type'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:stk='http://schemas.microsoft.com/soap-toolkit/wsdl-extension'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
#types>
#schema targetNamespace='http://tempuri.org/type'
xmlns='http://www.w3.org/2001/XMLSchema'
xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
elementFormDefault='qualified'>
#/schema>
#/types>
#message name='clsSOAP.getData'>
#part name='id' type='xsd:int'/>
#part name='name' type='xsd:string'/>
#/message>
#message name='clsSOAP.getDataResponse'>
#part name='Result' type='xsd:string'/>
#part name='id' type='xsd:int'/>
#part name='name' type='xsd:string'/>
#/message>
#portType name='clsSOAPSoapPort'>
#operation name='getData' parameterOrder='id name'>
#input message='wsdlns:clsSOAP.getData' />
#output message='wsdlns:clsSOAP.getDataResponse' />
#/operation>
#/portType>
#binding name='clsSOAPSoapBinding' type='wsdlns:clsSOAPSoapPort' >
#stk:binding preferredEncoding='UTF-8'/>
#soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http' />
#operation name='getData' >
#soap:operation soapAction='http://tempuri.org/action/clsSOAP.getData' />
#input>
#soap:body use='encoded' namespace='http://tempuri.org/message/'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' />
#/input>
#output>
#soap:body use='encoded' namespace='http://tempuri.org/message/'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' />
#/output>
#/operation>
#/binding>
#service name='SoapTest1' >
#port name='clsSOAPSoapPort' binding='wsdlns:clsSOAPSoapBinding' >
#soap:address location='http://127.0.0.1/soapListen/SoapTest1.ASP' />
#/port>
#/service>
#/definitions>



SOAP Client Code:

Private Sub Command1_Click()
Dim o As New soapClient
o.mssoapinit "http://localhost/soaplisten/soaptest1.wsdl"
MsgBox CStr(o.GetData(2, "b"))
End Sub