importing a wsdl file in delphi XE3 - delphi

I have to address a webservice with SOAP.
the WSDL file is http://www.healthconnect.be/sites/default/files/support/ConsultMyCareNet.wsdl
However when I import this WSDL file in my project (Delphi XE3) with file- new - other - WSDL importer there are some faults,
In top of the new *.pas file I find:
The following types, referred to in the WSDL document are not being represented
in this file. They are either aliases[#] of other types represented or were referred
to but never[!] declared in the document. The types from the latter category
typically map to predefined/known XML or Embarcadero types; however, they could also
indicate incorrect WSDL documents that failed to declare or import a schema type.*
// !:GetMCNStatusRequest - "urn:be:healthconnect:rrnconnector:ws:1_0:messages"
// !:GetMCNStatusResponse - "urn:be:healthconnect:rrnconnector:ws:1_0:messages"**
and thus the following important and necessary function for addressing the webservice cannot be compiled
with the message:
Cannot unwrap:
- Input part does not refer to an element
- Output part does not refer to an element*
function getMCNStatus(const parameters: GetMCNStatusRequest): GetMCNStatusResponse; stdcall;
But I need this function 'getMCNStatus' as It is a the first function to call since this function tests if the connection with the webservice is Ok. Without this function the rest does not work.
So how can I make this function work anyway?
Must I define the classes GetMCNStatusRequest and GetMCNStatusResponse myself and what Do I have to define in the classes ? Can I find the answer in the wsdl file ?

open your wsdl file.
Remove following lines within types tag.
<xs:import namespace="urn:be:healthconnect:rrnconnector:ws:1_0:person" schemaLocation="person-1-0.xsd" />
<xs:import namespace="urn:be:healthconnect:rrnconnector:ws:1_0:common" schemaLocation="common-1-0.xsd" />
<xs:import namespace="urn:be:healthconnect:rrnconnector:ws:1_0:messages" schemaLocation="messages-1-0.xsd" />
Now , you won't get any error while importing wsdl.
Update: Reason
Why is it happening?
Instead of defining element types in your wsdl file, you are importing these namespaces which has defined xsd files like person-1-0.xsd or common-1-0.xsd Which is not accessible. These namesapaces should be like
"http://healthconnect/example"

Related

AnsiString header file

I am migrating from an old version of Borland C++ to the newest. In my code I had used String (AnsiString). In the new compiler it does not recognize String or AnsiString as a valid type, so I put in vcl.h in the file where I use String. Now I get 103 errors, all saying "reference to byte is ambiguous" (various system .h files). Is vcl.h not the header for AnsiString?
thanks
The actual header file that defines AnsiString is dstring.h, and always has been (the header file that defines UnicodeString is ustring.h). The System::String alias is defined in sysmac.h.
vcl.h includes these headers for you. If you are getting errors, either you did not create a VCL project properly to begin with, or your project is misconfigured.

Node-soap with WSDL that imports another WSDL

I have a 2 WSDL files.
WSAPIService.wsdl
WSAPIServiceContract.wsdl
WSAPIService.wsdl references WSAPIServiceContract.wsdl another via an import tag.
<wsdl:import location="WSAPIServiceContract.wsdl" />
I was hoping node-soap would automatically pull in the referenced file, but it doesn't appear to be.
const client = await soap.createClientAsync('WSAPIService.wsdl')
Does anyone have experience with merging wsdl files or using node-soap with a wsdl with imports?
Thanks!
I have already tried:
https://github.com/pkielgithub/SchemaLightener - it failed with Exception: net.sf.saxon.trans.XPathException: Too many nested template or function calls. The stylesheet may be looping.
https://svn.apache.org/repos/asf/webservices/muse/site/docs/2.2.0/manual/tools/wsdlmerge.html This looked helpful but the download links are broken
Any advice would be greatly appreciated!

FSharp.Data: EmbeddedResource option is ignored

I am using the XML Type Provider with FSharp.Data. I have a line like this:
type internal SomethingFromXML = XmlProvider<"./Sample.xml", EmbeddedResource="MyLib, Sample.xml">
I set the Sample.xml to "Embedded Resource, Do Not Copy".
I packed the MyLib to a NuGet package and used it in another program. But when I now execute it, I get a DirectoryNotFoundException saying it can't find C:\Path\To\My\SolutionWithMyLib\MyLib\Sample.xml
So, it seems to ignore the EmbeddedResource directive. Is that not supported with the XML Provider, or am I missing anything?

Unable to load WSDL File/Location in Delphi for VIES SOAP Service

I am trying to create a Delphi XE2 function to check VAT numbers via the SOAP service of VIES: http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl
When I use Delphi X2's WSDL importer with the above URL taking the default values, I get the following error:
Unable to load WSDL File/Location: http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl. Error [The requested header was not found - URL:http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl - SOAPAction:""
What am I doing worng?
Save the wsdl file to disc and import the saved xml file.
After generating the pas file, change the line matchCode = (1, 2) in (_1, _2).

Any way to guess the mime type on Delphi XE2?

I need to guess the mime type with the purpose of fill the "Content-Type" header for some file uploads.
I fail to found a solution for it.
I wish to call something like: GetMimeType('C:File.jpg') and get back image/jpg.
Best if is multiplataform (for win/osx) but will be enough if only for windows.
Try using the FindMimeFromData Function.
FindMimeFromData contains hard-coded tests for (currently 26) separate
MIME types (see Known MIME Types). This means that if a given buffer
contains data in the format of one of these MIME types, a test exists
in FindMimeFromData that is designed (by scanning through the buffer
contents) to recognize the corresponding MIME type.
from urlmon.pas
function FindMimeFromData(
pBC: IBindCtx; // bind context - can be nil
pwzUrl: LPCWSTR; // url - can be nil
pBuffer: Pointer; // buffer with data to sniff - can be nil (pwzUrl must be valid)
cbSize: DWORD; // size of buffer
pwzMimeProposed: LPCWSTR; // proposed mime if - can be nil
dwMimeFlags: DWORD; // will be defined
out ppwzMimeOut: LPWSTR; // the suggested mime
dwReserved: DWORD // must be 0
): HResult; stdcall;
Also this article to see hot it works MIME Type Detection in Internet Explorer
IE uses GetClassFileOrMime and FindMimeFromData API to detect the mime type of data/files (UrlMon unit in Delphi).
MIME Type Detection in Internet Explorer
The CLSID returned from GetClassFileOrMime could be located in the registry under HKEY_CLASSES_ROOT\CLSID\<clsid>\MimeTypes. (also FileExtensions, FriendlyName).
The registry also holds a MIME database under: HKEY_CLASSES_ROOT\MIME\Database\Content Type.
But since the list of known MIME types is relatively small you could hold that as a resource XML (or whatever) and simply fetch it from there. This will supprt both Windows and OSX.
For file upload operation you can simply always use application/octet-stream.
Indy has TIdMimeTable class (IdGlobal) and it uses a fixed list plus inspecting the registry HKEY_CLASSES_ROOT (see FillMimeTable). If no match is found application/octet-stream is used.
You should probably want to inspect the file content at the server side once the file is uploaded, and not rely on the headers because the ContentType could be tampered at the client side, and also not match with the registry at the server-side.
Internet Direct (Indy) contains a class for this:
class TIdThreadSafeMimeTable
in unit IdCustomHTTPServer
Code example in a HTTP server application:
Response.ContentType :=
Response.HTTPServer.MIMETable.GetFileMIMEType(FileName);
How many file types are you talking about? Maybe you can just create a list of types you want to support.
I can imagine these lists to be available on the internet as well, for instance
here: http://www.webmaster-toolkit.com/mime-types.shtml
here: http://webdesign.about.com/od/multimedia/a/mime-types-by-file-extension.htm
here: List of ALL MimeTypes on the Planet, mapped to File Extensions?
here: http://hul.harvard.edu/ois/systems/wax/wax-public-help/mimetypes.htm
Just get the file extension using ExtractFileExt and check it agains one of those lists. A file doesn't have a mime type in it, so you'll need to use either this list of file extensions, or determine the type by reading the file headers, which is harder and just as unreliable.

Resources