C++ client for C# WCF service -



C++ client for C# WCF service -

i have created simple wcf service:

namespace wcfservicelibrary1 { [servicecontract] public interface iservice1 { [operationcontract] int getdata(int value); } } namespace wcfservicelibrary1 { public class service1 : iservice1 { public int getdata(int value) { homecoming 101; } } }

now need create c++ client it. have generated wsdl , later .h , .c files. , whole c++ client:

#ifndef unicode #define unicode #endif #include "webservices.h" #include "process.h" #include "stdio.h" #include "string.h" //#include "calculatorservice.wsdl.h" #include "webservices.h" #include "..\..\schemas.microsoft.com.2003.10.serialization.xsd.h" #include "..\..\tempuri.org.xsd.h" #include "..\..\tempuri.org.wsdl.h" // print out rich error info void printerror(hresult errorcode, ws_error* error) { wprintf(l"failure: errorcode=0x%lx\n", errorcode); if (errorcode == e_invalidarg || errorcode == ws_e_invalid_operation) { // right utilize of apis should never generate these errors wprintf(l"the error due invalid utilize of api. due bug in program.\n"); debugbreak(); } hresult hr = noerror; if (error != null) { ulong errorcount; hr = wsgeterrorproperty(error, ws_error_property_string_count, &errorcount, sizeof(errorcount)); if (failed(hr)) { goto exit; } (ulong = 0; < errorcount; i++) { ws_string string; hr = wsgeterrorstring(error, i, &string); if (failed(hr)) { goto exit; } wprintf(l"%.*s\n", string.length, string.chars); } } exit: if (failed(hr)) { wprintf(l"could not error string (errorcode=0x%lx)\n", hr); } } // main entry point int __cdecl wmain(int argc, __in_ecount(argc) wchar_t **argv) { unreferenced_parameter(argc); unreferenced_parameter(argv); ws_http_binding_template templ = {}; hresult hr = noerror; ws_error* error = null; ws_heap* heap = null; ws_service_proxy* proxy = null; int result = 0; ws_endpoint_address address = {}; ws_string url= ws_string_value(l"http://localhost:8733/design_time_addresses/wcfservicelibrary1/service1/mex"); address.url = url; // create error object storing rich error info hr = wscreateerror( null, 0, &error); if (failed(hr)) { goto exit; } // create heap store deserialized info hr = wscreateheap( /*maxsize*/ 2048, /*trimsize*/ 512, null, 0, &heap, error); if (failed(hr)) { goto exit; } hr = basichttpbinding_iservice1_createserviceproxy(&templ, null, 0, &proxy, error); hr = wsopenserviceproxy( proxy, &address, null, error); if (failed(hr)) { goto exit; } hr = basichttpbinding_iservice1_getdata( proxy, 4, &result, heap, null, 0, null, error); if (failed(hr)) { goto exit; } wprintf(l"%d + %d = %d\n", 1, 2, result); exit: if (failed(hr)) { // print out error printerror(hr, error); } fflush( stdout); if (proxy != null) { wscloseserviceproxy( proxy, null, null); wsfreeserviceproxy( proxy); } if (heap != null) { wsfreeheap(heap); } if (error != null) { wsfreeerror(error); } fflush(stdout); homecoming succeeded(hr) ? 0 : -1; }

and in output have error:

failure: errorcode=0x803d0000 there error communicating endpoint @ 'http://localhost:8733/design_time_addresses/wcfservicelibrary1/service1/mex'. server returned http status code '415 (0x19f)' text 'cannot process message because content type 'text/xml; charset=utf-8' not expected type 'application/soap+xml; charset=utf-8'.'. format of http request not supported server.

how find problem?

c# c++ wcf visual-c++

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -