📄 wsdloper.cpp
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft shared
// source or premium shared source license agreement under which you licensed
// this source code. If you did not accept the terms of the license agreement,
// you are not authorized to use this source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the SOURCE.RTF on your install media or the root of your tools installation.
// THE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
//+----------------------------------------------------------------------------
//
//
// File: wsdloper.cpp
//
// Contents:
//
// implementation file
//
// IWSDLReader Interface implemenation
//
//-----------------------------------------------------------------------------
#include "headers.h"
#include "wsdloper.h"
#include "soapmapr.h"
#include "ensoapmp.h"
#include "xsdpars.h"
BEGIN_INTERFACE_MAP(CWSDLOperation)
ADD_IUNKNOWN(CWSDLOperation, IWSDLOperation)
ADD_INTERFACE(CWSDLOperation, IWSDLOperation)
END_INTERFACE_MAP(CWSDLOperation)
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// function: CWSDLOperation::CWSDLOperation()
//
// parameters:
//
// description:
//
// returns:
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
CWSDLOperation::CWSDLOperation()
{
memset(this, 0, sizeof(CWSDLOperation));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// function: CWSDLOperation::~CWSDLOperation()
//
// parameters:
//
// description:
//
// returns:
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
CWSDLOperation::~CWSDLOperation()
{
TRACEL((3, "Operation shutdown %S\n", m_bstrName));
delete m_pWSDLInputMessage;
delete m_pWSDLOutputMessage;
delete [] m_ppchparameterOrder;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// function: CWSDLOperation::Shutdown(void)
//
// parameters:
//
// description:
// called by parent when he is destroyed
// returns:
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void CWSDLOperation::Shutdown(void)
{
CAutoRefc<CSoapMapper> pSoapMapper=0;
DWORD dwCookie;
// before we shut down, we need to tell all mappers to release
// their soaptypemapper interfaces, if they have any...
dwCookie = 0;
while(m_pEnumSoapMappers->getNext((ISoapMapper**)&pSoapMapper, &dwCookie)==S_OK)
{
pSoapMapper->Shutdown();
release(&pSoapMapper);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// function: HRESULT CWSDLOperation::get_name(BSTR *pbstrOperationName)
//
// parameters:
//
// description:
//
// returns:
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CWSDLOperation::get_name(BSTR *pbstrOperationName)
{
return _WSDLUtilReturnAutomationBSTR(pbstrOperationName , m_bstrName);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// function: HRESULT CWSDLOperation::get_style(BSTR *pbstrStyle)
//
// parameters:
//
// description:
// returns the style attribute for the operation
// returns:
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CWSDLOperation::get_style(BSTR *pbstrStyle)
{
return(_WSDLUtilGetStyleString(pbstrStyle, m_fDocumentMode));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// function: const WCHAR *CWSDLOperation::get_nameRef()
//
// parameters:
//
// description:
//
// returns:
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
const WCHAR * CWSDLOperation::getNameRef()
{
return (WCHAR *) m_bstrName;;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// function: HRESULT CWSDLOperation::get_documentation(BSTR *bstrServicedocumentation)
//
// parameters:
//
// description:
//
// returns:
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CWSDLOperation::get_documentation(BSTR *bstrServicedocumentation)
{
return _WSDLUtilReturnAutomationBSTR(bstrServicedocumentation, m_bstrDocumentation);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// function: HRESULT CWSDLOperation::get_soapAction(BSTR *pbstrSoapAction)
//
// parameters:
//
// description:
//
// returns:
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CWSDLOperation::get_soapAction(BSTR *pbstrSoapAction)
{
return _WSDLUtilReturnAutomationBSTR(pbstrSoapAction, m_bstrSoapAction);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// function: BOOL CWSDLOperation::compareSoapAction(TCHAR *pchSoapActionToCompare)
//
// parameters:
//
// description:
// compares a passed in string with the soapaction property.
// returns:
// true if matches
/////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL CWSDLOperation::compareSoapAction(TCHAR *pchSoapActionToCompare)
{
if (pchSoapActionToCompare)
{
return(wcscmp(pchSoapActionToCompare, m_bstrSoapAction)==0);
}
return(FALSE);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// function: HRESULT CWSDLOperation::GetOperationParts(IEnumSoapMappers * ppIEnumSoapMappers)
//
// parameters:
//
// description:
//
// returns:
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CWSDLOperation::GetOperationParts(IEnumSoapMappers **ppIEnumSoapMappers)
{
ASSERT(m_pEnumSoapMappers!=0);
if (ppIEnumSoapMappers==0)
return(E_INVALIDARG);
return(m_pEnumSoapMappers->Clone(ppIEnumSoapMappers));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef CE_NO_EXCEPTIONS
HRESULT
SafeInvoke(IDispatch *pD, BOOL *fException,
DISPID dispIdMember,
REFIID riid, LCID lcid,
WORD wFlags,
DISPPARAMS FAR *pDispParams,
VARIANT FAR *pVarResult,
EXCEPINFO FAR *pExcepInfo,
unsigned int FAR *puArgErr)
{
HRESULT hr;
__try{
*fException = FALSE;
hr = pD->Invoke(dispIdMember,
riid,
lcid,
wFlags,
pDispParams,
pVarResult,
pExcepInfo,
puArgErr);
return hr;
}
__except(1){
*fException = TRUE;
return E_FAIL;
}
}
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// function: HRESULT CWSDLOperation::ExecuteOperation(ISoapReader *pISoapReader, ISoapSerializer *pISoapSerializer)
//
// parameters:
//
// description:
//
// returns:
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CWSDLOperation::ExecuteOperation(ISoapReader *pISoapReader, ISoapSerializer *pISoapSerializer)
{
HRESULT hr = E_INVALIDARG;
DISPID dispid;
#ifndef UNDER_CE
long lRes;
#endif
DISPPARAMS dispparams;
VARIANTARG *pvarg=0;
VARIANT *pvBuffer=0;
VARIANT varRes;
EXCEPINFO exceptInfo;
unsigned int uArgErr;
smIsInputEnum enInput;
LPOLESTR p;
LONG lCallIndex;
LONG lVarType;
DWORD dwCookie;
CAutoRefc<ISoapMapper> pSoapMapper=0;
CAutoRefc<IDispatch> pDispatch=0;
CAutoRefc<IHeaderHandler> pHeaderHandler=0;
CSoapHeaders soapHeaders;
VariantInit(&varRes);
memset(&dispparams, 0, sizeof dispparams);
memset(&exceptInfo, 0, sizeof(EXCEPINFO));
if (!m_pDispatchHolder)
goto Cleanup;
hr = m_pDispatchHolder->GetDispatchPointer(&pDispatch);
ERROR_ONHR1( hr, WSDL_IDS_OPERNOOBJECT, WSDL_IDS_OPERATION, m_bstrMethodName);
// do header preprocessing
if (m_pHeaderHandler)
{
hr = m_pHeaderHandler->GetHeaderPointer(&pHeaderHandler);
ERROR_ONHR1( hr, WSDL_IDS_OPERNOHEADERHANDLER, WSDL_IDS_OPERATION, m_bstrMethodName);
}
// init the helper class
CHK(soapHeaders.Init());
CHK(soapHeaders.AddHeaderHandler(pHeaderHandler));
hr = soapHeaders.ReadHeaders(pISoapReader , pDispatch);
ERROR_ONHR1( hr, WSDL_IDS_OPERREADHEADERSFAILED, WSDL_IDS_OPERATION, m_bstrMethodName);
if (m_dispID == DISPID_UNKNOWN)
{
p = m_bstrMethodName;
// dispid was not provided in the WSML file
hr = pDispatch->GetIDsOfNames(IID_NULL, &p,1,LOCALE_SYSTEM_DEFAULT, &dispid);
ERROR_ONHR1( hr, WSDL_IDS_OPERNODISPIDFOUND, WSDL_IDS_OPERATION, m_bstrMethodName);
}
else
{
dispid = m_dispID;
}
// now build the dispparam array
CHK (m_pEnumSoapMappers->CountOfArguments((long*)&(dispparams.cArgs)));
if (dispparams.cArgs > 0)
{
pvarg = new VARIANTARG[dispparams.cArgs];
pvBuffer = new VARIANT[dispparams.cArgs];
CHK_BOOL ( pvarg && pvBuffer, E_OUTOFMEMORY);
dispparams.rgvarg = pvarg;
memset(pvarg, 0, sizeof(VARIANTARG) * dispparams.cArgs);
memset(pvBuffer, 0, sizeof(VARIANT) * dispparams.cArgs);
// everything setup, now walk the enum to set those guys up. Fill them backwards (parameter passing is
// in reversed order
dwCookie = 0;
while ((hr = m_pEnumSoapMappers->getNext(&pSoapMapper, &dwCookie))==S_OK)
{
CHK ( pSoapMapper->get_callIndex(&lCallIndex) );
// now check where the guy goes to
if (lCallIndex != -1)
{
// that indicates this is the return value, so ignore him
// remember opposite order for the position;
lCallIndex = dispparams.cArgs - lCallIndex;
VARIANT* _pvarg = &(pvarg[lCallIndex]);
CHK ( pSoapMapper->get_comValue(_pvarg) );
CHK(pSoapMapper->get_isInput(&enInput));
CHK(pSoapMapper->get_variantType(&lVarType));
if (enInput != smInput)
{
// do not create a byref handle in case of a safearray | dispatch
// if ((VT_ARRAY | VT_DISPATCH) != V_VT(_pvarg))
{
// now this indicates by ref for us
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -