1

Is there a good reason for the native web services compiler to generate a WCHAR * for an xsd:string vs a const wchar_t* (or LPCWSTR in short)?

The reason I state this question is that ours is a native c++ application which has std::wstrings floating around in the code that needs to be passed into a WCF service. In order to use the C functions generated by the native web services compiler it's forcing me to do something on the lines of e.g.

MyCppFunc(const std::wstring& inputString ,…)
{
… 
    HRESULT hr = BasicHttpBinding_BlahService(const_cast<<WCHAR*>WCHAR*>(inputString.c_str()), ….); 
}

As seen from above I am forced to do away with the const on the pointer, my point of concern here is by explicitly having a WCHAR* type is the pointer data expected to get manipulated by the webservices.lib itself in anyway?

Alternatively I could end up copying over the contents of the string to a WCHAR* but for the fact that our c++ app runs as a service and we have heap fragmentation concerns over the frequent allocations/de-allocations.

Thanks., Raghu

Charles
  • 50,943
  • 13
  • 104
  • 142
Raghu
  • 21
  • 3

0 Answers0