none
Error 0x803d0008 - maximum length of string exceeded RRS feed

  • Question

  • I am using the Windows Web Services API in C++ to connect to a Java SOAP web service. I have followed the examples online and you can see my code below.  During the actual service call I am getting this error: 0x803d0008 - maximum length of string exceeded

    I am able to successfully call the service from C# using the WCF APIs.  How can I fix the "maximum length of string exceeded error" in the C++ version?

    #include <WebServices.h>
    #include "xxx.xsd.h"
    #include "xxx.wsdl.h"
    #include <string>
    #include <iostream>
    #include <memory>
    #include <limits>
    #include <vector>
    
    void PrintError(HRESULT errorCode, WS_ERROR* error);
    
    int main(int argc, char* argv)
    {
    	HRESULT hr = ERROR_SUCCESS;
    	WS_ERROR* error = NULL;
    	WS_HEAP* heap = NULL;
    	WS_SERVICE_PROXY* proxy = NULL;
    
    	WS_ENDPOINT_ADDRESS address = {};
    	WS_STRING url = WS_STRING_VALUE(L"xxx");
    	address.url = url;
    
    	hr = WsCreateError(NULL, 0, &error);
    	if (FAILED(hr)) {
    		PrintError(hr, error);
    	}
    
    	hr = WsCreateHeap(2147483647, 512, NULL, 0, &heap, error);
    	if (FAILED(hr)) {
    		PrintError(hr, error);
    	}
    
    	// declare and initialize an SSL transport security binding
    	WS_SSL_TRANSPORT_SECURITY_BINDING sslBinding = {}; // zero out the struct
    	sslBinding.binding.bindingType = WS_SSL_TRANSPORT_SECURITY_BINDING_TYPE; // set the binding type
    
    	// declare and initialize the array of all security bindings
    	WS_SECURITY_BINDING* securityBindings[1] = { &sslBinding.binding };
    
    	// declare and initialize the security description
    	WS_SECURITY_DESCRIPTION securityDescription = {}; // zero out the struct
    	securityDescription.securityBindings = securityBindings;
    	securityDescription.securityBindingCount = WsCountOf(securityBindings);
    
    	WS_ENCODING encoding = WS_ENCODING_XML_UTF8;
    	WS_ENVELOPE_VERSION soapVersion = WS_ENVELOPE_VERSION_SOAP_1_1;
    	ULONG maxReceivedMessageSize = 2147483647;
    	WS_CHANNEL_PROPERTY channelProperties[3] =
    	{
    		{ WS_CHANNEL_PROPERTY_ENVELOPE_VERSION, &soapVersion, sizeof(soapVersion) },
    		{ WS_CHANNEL_PROPERTY_ENCODING, &encoding, sizeof(encoding) },
    		{ WS_CHANNEL_PROPERTY_MAX_BUFFERED_MESSAGE_SIZE, &maxReceivedMessageSize, sizeof(maxReceivedMessageSize) },
    	};
    
    	//Create proxy
    	hr = WsCreateServiceProxy(
    		WS_CHANNEL_TYPE_REQUEST,
    		WS_HTTP_CHANNEL_BINDING,
    		&securityDescription,
    		NULL,
    		0,
    		channelProperties,
    		2,
    		&proxy,
    		error);
    
    	hr = WsOpenServiceProxy(proxy, &address, NULL, error);
    	if (FAILED(hr)) {
    		PrintError(hr, error);
    	}
    
    //Actual service call commented out for confidentially reasons
    	
    	if (proxy != NULL)
    	{
    		WsCloseServiceProxy(proxy, NULL, NULL);
    		WsFreeServiceProxy(proxy);
    	}
    
    	if (heap != NULL)
    	{
    		WsFreeHeap(heap);
    	}
    	if (error != NULL)
    	{
    		WsFreeError(error);
    	}
    }
    
    // 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)
    	{
    		// Correct use of the APIs should never generate these errors
    		wprintf(L"The error was due to an invalid use of an API.  This is likely due to a bug in the 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;
    		}
    		for (ULONG i = 0; i < errorCount; i++)
    		{
    			WS_STRING string;
    			hr = WsGetErrorString(error, i, &string);
    			if (FAILED(hr))
    			{
    				goto Exit;
    			}
    			wprintf(L"%.*s\n", string.length, string.chars);
    		}
    	}
    	DebugBreak();
    Exit:
    	if (FAILED(hr))
    	{
    		wprintf(L"Could not get error string (errorCode=0x%lx)\n", hr);
    	}
    }
    

    Thursday, February 11, 2016 2:03 PM

All replies

  • For reference, here is the C# app.config configuration section:

    <system.serviceModel>
        <bindings>
          <customBinding>
            <binding name="PortBinding">
              <transactionFlow transactionProtocol="WSAtomicTransactionOctober2004" />
              <textMessageEncoding messageVersion="Soap11" />
              <httpsTransport />
            </binding>
          </customBinding>
        </bindings>
        <client>
          <endpoint
              binding="customBinding" bindingConfiguration="PortBinding"
              contract="xxxxWSCatalogDropDown" name="DropDownPort" />
        </client>
      </system.serviceModel>

    Thursday, February 11, 2016 2:04 PM