Ejemplo n.º 1
0
TAG_METHOD_IMPL(CWSDLOperationParser, OnFault)
{
	TRACE_PARSE_ENTRY();

	CWSDLPortTypeOperation * pCurr = GetOperation();
	if (pCurr != NULL)
	{
		CWSDLPortTypeFault * pElem = pCurr->AddFault();
		if (pElem != NULL)
		{
			SetXMLElementInfo(pElem, pCurr, GetLocator());
			CAutoPtr<CWSDLOperationIOParser> p( new CWSDLOperationIOParser(GetReader(), this, GetLevel(), pElem) );
			if (p != NULL)
			{
				if (g_ParserList.AddHead(p) != NULL)
				{
					return p.Detach()->GetAttributes(pAttributes);
				}
			}
		}
	}

	EmitErrorHr(E_OUTOFMEMORY);

	return E_FAIL;
}
Ejemplo n.º 2
0
TAG_METHOD_IMPL(CWSDLBindingParser, OnOperation)
{
	TRACE_PARSE_ENTRY();
	
	CWSDLBinding * pCurr = GetBinding();
	if (pCurr != NULL)
	{
		CAutoPtr<CWSDLPortTypeOperation> spElem;
		spElem.Attach( new CWSDLPortTypeOperation );

		if (spElem != NULL)
		{
			SetXMLElementInfo(spElem, pCurr, GetLocator());

			CAutoPtr<CWSDLOperationParser> p( new CWSDLOperationParser(GetReader(), this, GetLevel(), spElem) );
			if (p)
			{
				if (g_ParserList.AddHead(p) != NULL)
				{
					if (SUCCEEDED(p.Detach()->GetAttributes(pAttributes)))
					{
						if (pCurr->AddOperation(spElem) != NULL)
						{
							spElem.Detach();
							return S_OK;
						}
					}
				}
			}
		}
	}

	EmitErrorHr(E_OUTOFMEMORY);
	return E_FAIL;
}
Ejemplo n.º 3
0
TAG_METHOD_IMPL(CWSDLOperationParser, OnHttpOperation)
{
	TRACE_PARSE_ENTRY();

	CWSDLPortTypeOperation * pCurr = GetOperation();
	if (pCurr != NULL)
	{
		CHttpOperation *pOperation = pCurr->AddHttpOperation();
		if (pOperation != NULL)
		{
			CStringW strLocation;
			if (S_OK == GetAttribute(pAttributes, L"location", sizeof("location")-1, strLocation))
			{
				if (SUCCEEDED(pOperation->SetLocation(strLocation)))
				{
					return SkipElement();
				}
			}
			OnMissingAttribute(TRUE, L"location", sizeof("location")-1, L"", 0);
		}
	}

	EmitErrorHr(E_OUTOFMEMORY);

	return E_FAIL;
}
Ejemplo n.º 4
0
TAG_METHOD_IMPL(CElementParser, OnComplexType)
{
    TRACE_PARSE_ENTRY();

    CElement * pCurr = GetElement();
    if (pCurr != NULL)
    {
        CComplexType * pElem = pCurr->AddComplexType();
        if (pElem != NULL)
        {
            SetXSDElementInfo(pElem, pCurr, GetLocator());

            CAutoPtr<CComplexTypeParser> p( new CComplexTypeParser(GetReader(), this, GetLevel(), pElem) );
            if (p != NULL)
            {
                if (g_ParserList.AddHead(p) != NULL)
                {
                    return p.Detach()->GetAttributes(pAttributes);
                }
            }
        }
    }

    EmitErrorHr(E_OUTOFMEMORY);
    return E_FAIL;
}
Ejemplo n.º 5
0
TAG_METHOD_IMPL(CWSDLBindingParser, OnHttpBinding)
{
	TRACE_PARSE_ENTRY();

	CWSDLBinding * pCurr = GetBinding();
	if (pCurr != NULL)
	{
		CHttpBinding *pBinding = pCurr->AddHttpBinding();
		if (pBinding != NULL)
		{
			SetXMLElementInfo(pBinding, pCurr, GetLocator());

			CStringW strVerb;
			if (S_OK == GetAttribute(pAttributes, L"verb", sizeof("verb")-1, strVerb))
			{
				if (SUCCEEDED(pBinding->SetVerb(strVerb)))
				{
					return SkipElement();
				}
			}
		}
	}

	EmitErrorHr(E_OUTOFMEMORY);

	return E_FAIL;
}
Ejemplo n.º 6
0
HRESULT CXMLElement::SetNamespaceUri(const CStringW& strPrefix, CStringW &strUri)
{
	if (m_namespaceMap.SetAt(strPrefix, strUri) != NULL)
	{
		return S_OK;
	}
	EmitErrorHr(E_OUTOFMEMORY);
	return E_FAIL;
}
Ejemplo n.º 7
0
ATTR_METHOD_IMPL(CContentParser, OnID)
{
	TRACE_PARSE_ENTRY();

	CContent *pCurr = GetContent();
	if (pCurr != NULL)
	{
		return pCurr->SetID(wszValue, cchValue);
	}

	EmitErrorHr(E_OUTOFMEMORY);
	return E_FAIL;
}
Ejemplo n.º 8
0
ATTR_METHOD_IMPL(CWSDLServiceParser, OnName)
{
	TRACE_PARSE_ENTRY();

	CWSDLService * pCurr = GetService();
	if (pCurr != NULL)
	{
		return pCurr->SetName(wszValue, cchValue);
	}

	EmitErrorHr(E_OUTOFMEMORY);

	return E_FAIL;
}
Ejemplo n.º 9
0
ATTR_METHOD_IMPL(CContentParser, OnMixed)
{
	TRACE_PARSE_ENTRY();

	CContent *pCurr = GetContent();
	if (pCurr != NULL)
	{
		if (SUCCEEDED(pCurr->SetMixed(wszValue, cchValue)))
		{
			return S_OK;
		}
		EmitInvalidValue("mixed", wszValue);
	}

	EmitErrorHr(E_OUTOFMEMORY);

	return E_FAIL;
}
Ejemplo n.º 10
0
TAG_METHOD_IMPL(CWSDLOperationParser, OnSoapOperation)
{
	TRACE_PARSE_ENTRY();

	CWSDLPortTypeOperation * pCurr = GetOperation();
	if (pCurr != NULL)
	{
		CSoapOperation *pOperation = pCurr->AddSoapOperation();
		if (pOperation != NULL)
		{
			CStringW strSoapAction;
			if (S_OK == GetAttribute(pAttributes, L"soapAction", sizeof("soapAction")-1, strSoapAction))
			{
				pOperation->SetSoapAction(strSoapAction);
			}

			const wchar_t *wszStyle;
			int cchStyle;
			HRESULT hr = S_OK;
			if (S_OK == GetAttribute(pAttributes, L"style", sizeof("style")-1, &wszStyle, &cchStyle))
			{
				hr = pOperation->SetStyle(wszStyle, cchStyle);
				if (FAILED(hr))
				{
					EmitInvalidValue("style", wszStyle);
				}
			}

			if (SUCCEEDED(hr))
			{
				return SkipElement();
			}
			else
			{
				OnMissingAttribute(TRUE, L"style", sizeof("style")-1, L"", 0);
			}
		}

	}

	EmitErrorHr(E_OUTOFMEMORY);

	return E_FAIL;
}
Ejemplo n.º 11
0
TAG_METHOD_IMPL(CWSDLMessageParser, OnPart)
{
	TRACE_PARSE_ENTRY();

	CWSDLMessage *pCurr = GetMessage();
	if (pCurr != NULL)
	{
		CWSDLMessagePart *pPart = pCurr->AddPart();
		if (pPart != NULL)
		{
			SetXMLElementInfo(pPart, pCurr, GetLocator());

			CStringW strName;
			if (S_OK == GetAttribute(pAttributes, L"name", sizeof("name")-1, strName))
			{
				pPart->SetName(strName);
				
				CStringW strElement;
				if (S_OK == GetAttribute(pAttributes, L"element", sizeof("element")-1, strElement))
				{
					pPart->SetElement(strElement);
				}
				CStringW strType;
				if (S_OK == GetAttribute(pAttributes, L"type", sizeof("type")-1, strType))
				{
					pPart->SetType(strType);
				}
//				else
//				{
//					OnMissingAttribute(TRUE, L"element", sizeof("element")-1, L"", 0);
//				}

				return SkipElement();
			}
			OnMissingAttribute(TRUE, L"name", sizeof("name")-1, L"", 0);
		}
	}

	EmitErrorHr(E_OUTOFMEMORY);

	return E_FAIL;
}
Ejemplo n.º 12
0
TAG_METHOD_IMPL(CWSDLBindingParser, OnSoapBinding)
{
	TRACE_PARSE_ENTRY();

	CWSDLBinding * pCurr = GetBinding();
	if (pCurr != NULL)
	{
		CSoapBinding *pBinding = pCurr->AddSoapBinding();
		if (pBinding != NULL)
		{
			SetXMLElementInfo(pBinding, pCurr, GetLocator());

			CStringW strTransport;
			if (S_OK == GetAttribute(pAttributes, L"transport", sizeof("transport")-1, strTransport))
			{
				pBinding->SetTransport(strTransport);
			}

			const wchar_t *wszStyle;
			int cchStyle;
			HRESULT hr = S_OK;
			if (S_OK == GetAttribute(pAttributes, L"style", sizeof("style")-1, &wszStyle, &cchStyle))
			{
				hr = pBinding->SetStyle(wszStyle, cchStyle);
				if (FAILED(hr))
				{
					EmitInvalidValue("style", wszStyle);
				}
			}

			if (SUCCEEDED(hr))
			{
				return SkipElement();
			}
		}

	}

	EmitErrorHr(E_OUTOFMEMORY);

	return E_FAIL;
}
Ejemplo n.º 13
0
ATTR_METHOD_IMPL(CElementParser, OnNillable)
{
    TRACE_PARSE_ENTRY();

    CElement * pCurr = GetElement();
    if (pCurr != NULL)
    {
        bool bVal;
        HRESULT hr = GetBooleanValue(&bVal, wszValue, cchValue);
        if (SUCCEEDED(hr))
        {
            pCurr->SetNullable(bVal);
            return S_OK;
        }

        EmitInvalidValue("nillable", wszValue);
    }

    EmitErrorHr(E_OUTOFMEMORY);
    return E_FAIL;
}
Ejemplo n.º 14
0
TAG_METHOD_IMPL(CSchemaParser, OnElement)
{
	TRACE_PARSE_ENTRY();

	CSchema * pCurr = GetSchema();
	if (pCurr != NULL)
	{
		CAutoPtr<CElement> spElem;
		spElem.Attach( new CElement );
		if (spElem != NULL)
		{
			SetXSDElementInfo(spElem, pCurr, GetLocator());
			spElem->SetParentSchema(pCurr);

			CAutoPtr<CElementParser> p( new CElementParser(GetReader(), this, GetLevel(), spElem) );
			if (p != NULL)
			{
				if (g_ParserList.AddHead(p) != NULL)
				{
					if (SUCCEEDED(p.Detach()->GetAttributes(pAttributes)))
					{
						if (spElem->GetName().GetLength() != 0)
						{
							if (pCurr->AddElement(spElem) != NULL)
							{
								spElem.Detach();
								return S_OK;
							}
						}
						EmitNamedElementError("element");
					}
				}
			}
		}
	}

	EmitErrorHr(E_OUTOFMEMORY);

	return E_FAIL;
}
Ejemplo n.º 15
0
TAG_METHOD_IMPL(CComplexTypeParser, OnComplexContent)
{
	TRACE_PARSE_ENTRY();

	CComplexType *pCurr = GetComplexType();

	if (pCurr != NULL)
	{
		if (pCurr->GetElementType() == XSD_COMPLEXTYPE)
		{
			CContent *pElem = pCurr->AddContent();
			if (pElem != NULL)
			{
				SetXSDElementInfo(pElem, pCurr, GetLocator());
				pElem->SetElementType(XSD_COMPLEXCONTENT);

				CAutoPtr<CContentParser> p( new CContentParser(GetReader(), this, GetLevel(), pElem) );
				if (p != NULL)
				{
					if (g_ParserList.AddHead(p) != NULL)
					{
						return p.Detach()->GetAttributes(pAttributes);
					}
				}
			}
		}
		else
		{
			return OnUnrecognizedTag(wszNamespaceUri, 
				cchNamespaceUri, wszLocalName, cchLocalName, 
				wszQName, cchQName, pAttributes);
		}
	}

	EmitErrorHr(E_OUTOFMEMORY);

	return E_FAIL;
}
Ejemplo n.º 16
0
int sproxy()
{
	unsigned __int64 nFlags;
	BOOL bHasInvalid;
	CStringW wszUrl;
	CStringW wszOut;
	CStringA szNamespace;
	wchar_t **argvW = NULL ;
	int argc = 0 ;

	argvW = CommandLineToArgvW(GetCommandLineW(),&argc);
	if(argvW == NULL)
	{
		EmitError(IDS_SDL_CMDLINE_FAILURE, GetLastError());
		return 1;
	}
	PreProcessCommandLine(argc, argvW, wszOut, szNamespace, &nFlags, &bHasInvalid);
	
	g_bUseWchar_t = ((nFlags & SPROXYFLAG_NOWCHAR_T) == 0);

	if ((nFlags & SPROXYFLAG_NOLOGO) == 0)
	{
		PrintHeader();
	}
	
	if (nFlags & SPROXYFLAG_USAGE)
	{
		PrintUsage(true);
		GlobalFree(argvW);
		return 0;
	}

	ParseCommandLine(argc, argvW, wszUrl, bHasInvalid);

	GlobalFree(argvW);	

	bHasInvalid = FALSE;
	if (wszUrl.IsEmpty())
	{
		EmitCmdLineError(IDS_SDL_MISSING_OPTION, nFlags & SPROXYFLAG_WSDLINPUT ?"<wsdl_location>":"<discomap_location>");
		bHasInvalid = TRUE;
	}

	if (bHasInvalid != FALSE)
	{
		printf("\r\n");
		PrintUsage();
		return 1;
	}

	if (nFlags & SPROXYFLAG_NOWARN)
	{
		SetEmitWarnings(false);
	}

	CHeapPtr<char> spSzNamespace;

	if (szNamespace && *szNamespace)
	{
		if (FAILED(CreateSafeCppName(&spSzNamespace, szNamespace)))
		{
			EmitErrorHr(E_OUTOFMEMORY);
			return 1;
		}
	}

	CoInitialize(NULL);
	HRESULT hr = S_OK;
	{
		CAutoPtr<CDiscoMapParser> dmParser;
		if(!(nFlags & SPROXYFLAG_WSDLINPUT))
		{
			CComPtr<ISAXXMLReader> spDMReader;
			hr = CoCreateInstance(__uuidof(SAXXMLReader30), NULL, CLSCTX_ALL,
				__uuidof(ISAXXMLReader), (void **)&spDMReader);

			if (FAILED(hr))
			{
				ATLTRACE( _T("CoCreateInstance failed!\n") );
				return 1;
			}

			dmParser.Attach(new CDiscoMapParser(spDMReader, NULL, 0));
			if(dmParser == NULL)
			{
				ATLTRACE(_T("Failed to create Discomap Parser : out of memory!\n"));
				return 1;
			}
			dmParser->SetDynamicAlloc(FALSE);
			hr = spDMReader->putContentHandler( dmParser );
			if (FAILED(hr))
			{
				ATLTRACE( _T("putContentHandler failed!\n") );
				return 1;
			}
			
			CErrorHandler errDM;
			errDM.SetLocation(wszUrl);

			hr = spDMReader->putErrorHandler( &errDM);
			if (FAILED(hr))
			{
				ATLTRACE( _T("putErrorHandler failed!\n") );
				return 1;
			}

			g_pDMDoc = dmParser->GetDiscoMapDocument();
			if (g_pDMDoc == NULL)
			{
				ATLTRACE( _T("failed to create document: out of memory!\n") );
				return 1;
			}
			

			hr = g_pDMDoc->SetDocumentUri( wszUrl, wszUrl.GetLength());

			if (FAILED(hr))
			{
				ATLTRACE( _T("failed to set document uri: out of memory!\n") );
				return 1;
			}

			g_wszFile = wszUrl;

			hr = spDMReader->parseURL( wszUrl );
			if (FAILED(hr))
			{
				ATLTRACE( _T("parseURL failed!\n") );
				if ((hr == E_SAX_LOADFAILED) || 
					(hr == E_SAX_FILENOTFOUND) ||
					(hr == E_SAX_PATHNOTFOUND) ||
					(hr == E_SAX_ACCESSDENIED))
				{
					EmitError(IDS_SDL_FAILED_DM_OPEN, wszUrl);
				}
				EmitError(IDS_SDL_PROCESS_DM_FAILURE, wszUrl);
				return 1;
			}
		}

		if(nFlags & SPROXYFLAG_WSDLINPUT)
			g_wszFile = wszUrl;
		else
			g_wszFile = g_pDMDoc->GetWSDLFile();

		CComPtr<ISAXXMLReader> spReader;
		hr = CoCreateInstance(__uuidof(SAXXMLReader30), NULL, CLSCTX_ALL,
			__uuidof(ISAXXMLReader), (void **)&spReader);

		if (FAILED(hr))
		{
			ATLTRACE( _T("CoCreateInstance failed!\n") );
			return 1;
		}

		CWSDLParser parser(spReader, NULL, 0);
		parser.SetDynamicAlloc(FALSE);
		hr = spReader->putContentHandler( &parser );
		if (FAILED(hr))
		{
			ATLTRACE( _T("putContentHandler failed!\n") );
			return 1;
		}

		CErrorHandler err;
		err.SetLocation(g_wszFile);

		hr = spReader->putErrorHandler( &err );
		if (FAILED(hr))
		{
			ATLTRACE( _T("putErrorHandler failed!\n") );
			return 1;
		}

		CWSDLDocument * pDoc = parser.GetWSDLDocument();
		if (pDoc == NULL)
		{
			ATLTRACE( _T("failed to create document: out of memory!\n") );
			return 1;
		}
		
		hr = pDoc->SetDocumentUri( g_wszFile, g_wszFile.GetLength());
		if (FAILED(hr))
		{
			ATLTRACE( _T("failed to set document uri: out of memory!\n") );
			return 1;
		}

		wchar_t wszTmp[ATL_URL_MAX_URL_LENGTH];
		if(g_wszFile.Find(L"://") != -1 && ((g_wszFile.Left(5)).MakeLower() != L"file:") )
		{
			// The URL needs to be escaped only if it's not a local file
			if(AtlEscapeUrl(g_wszFile,wszTmp,0,ATL_URL_MAX_URL_LENGTH-1,ATL_URL_BROWSER_MODE) == FALSE)
			{
				ATLTRACE( _T("failed to escape uri!\n") );
				return 1;
			}

			hr = spReader->parseURL( wszTmp );
		}
		else
		{
			hr = spReader->parseURL( g_wszFile );
		}
		
		if (FAILED(hr))
		{
			ATLTRACE( _T("parseURL failed!\n") );
			if ((hr == E_SAX_LOADFAILED) || 
			    (hr == E_SAX_FILENOTFOUND) ||
			    (hr == E_SAX_PATHNOTFOUND) ||
			    (hr == E_SAX_ACCESSDENIED))
			{
				EmitError(IDS_SDL_FAILED_WSDL_OPEN, g_wszFile);
			}
			EmitError(IDS_SDL_PROCESS_FAILURE, g_wszFile);
			return 1;
		}

		CCodeTypeBuilder builder;
		CCodeProxy proxy;
		hr = builder.Initialize(parser.GetWSDLDocument(), &proxy);

		if (FAILED(hr))
		{
			ATLTRACE( _T("builder.Initialize failed!\n") );
			return PrintGenerateFailure(wszOut);
		}

		hr = builder.Build();
		if (FAILED(hr))
		{
			ATLTRACE( _T("builder.Build failed!\n") );
			return PrintGenerateFailure(wszOut);
		}

		if (wszOut.IsEmpty())
		{
			wszOut.Preallocate(proxy.GetServiceName().GetLength()+4);
			wszOut = (LPCSTR)proxy.GetServiceName();
			wszOut.Append(L".h", 2);
		}

		Emit(IDS_SDL_SUCCESS, wszOut);
		CComObjectStack<CCppCodeGenerator> gen;
		hr = gen.Generate(wszOut, &proxy, 
				(nFlags & SPROXYFLAG_NOPRAGMA) ? false : true, 
				(nFlags & SPROXYFLAG_NOCLOBBER) ? true : false,
				(nFlags & SPROXYFLAG_NONAMESPACE) ? false : true,
				(nFlags & SPROXYFLAG_NOPROXY) ? false : true,
				spSzNamespace ? spSzNamespace : (szNamespace.IsEmpty() ? 0 : LPCSTR(szNamespace)));
		if (FAILED(hr))
		{
			ATLTRACE( _T("gen.Generate failed!\n") );
			return PrintGenerateFailure(wszOut);
		}
	}
	CoUninitialize();

	return 0;
}