⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wsdloper.cpp

📁 Windows CE 6.0 Server 源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    if (FAILED(hr))
    {
        globalAddError(WSDL_IDS_OPERMSGPARTNF, WSDL_IDS_OPERATION, hr, bstrPartName);
        goto Cleanup;
    }
    pPart.Clear();

    CHK(autoFormat.sprintf(_T("//def:message[@name=\"%s\"]/def:part"), bstrPartName));
    hr = _XPATHUtilFindNodeListFromRoot(pOperationNode, &autoFormat, &pNodeList);
    if (FAILED(hr))
    {
        // that's fine, there don't need to be parts,could be a message with NO parameters
        hr = S_OK;
        goto Cleanup;
    }

    if (m_fIsLiteral && pParent->isDocumentMode())
    {
        // feature hack. This is to support the part name=parameters that .NET is generating
        hr = pNodeList->get_length(&lLength);
        if (FAILED(hr))
        {
            goto Cleanup;
        }
        if (lLength == 1)
        {
            hr = pNodeList->nextNode(&pPart);
            if (FAILED(hr))
            {
                goto Cleanup;
            }
            // reset the nodelist for the standard enum below
            pNodeList->reset();

            if (pPart)
            {
                CAutoBSTR bstrTemp;
                hr = _WSDLUtilFindAttribute(pPart, _T("name"),  &bstrTemp);
                if (FAILED(hr))
                {
                    globalAddError(WSDL_IDS_MAPPERNONAME, WSDL_IDS_MAPPER, hr);
                    goto Cleanup;
                }
                if (_tcscmp(bstrTemp, _T("parameters"))==0)
                {
                    hr = _WSDLUtilFindAttribute(pPart, _T("element"),  &bstrParameterWithPrefix);
                    if (SUCCEEDED(hr))
                    {
                        // got it. this is the case where we need to expand one part into LOT's of MAPPERs.
                        hr = _XSDFindChildElements(pPart, &pSubList, bstrParameterWithPrefix, WSDL_IDS_OPERATION, &bstrNSUri);
                        if (FAILED(hr))
                        {
                            globalAddError(WSDL_IDS_CREATINGPARAMETERS, WSDL_IDS_OPERATION, hr, bstrTemp, m_bstrMessageName);
                            goto Cleanup;
                        }
                        // remove the prefix from the wrapper
                        CHK(_WSDLUtilSplitQName(bstrParameterWithPrefix, 0, &m_bstrParametersWrapper));
                        // take the schemanamespace
                        CHK(m_bstrNameSpace.Assign(bstrNSUri));
                        pNodeList.Clear();
                        pNodeList = pSubList.PvReturn();
                        m_fWrapperNeeded = true;
                    }
                }
            }
        }
        else
        {
            // so we have more than ONE part. Check that there is NO type in there, otherwise throw error
            // per spec, in document/literal, you are NOT allowed to have more than one type, or type/elements mixed
            CAutoRefc<IXMLDOMNodeList> pTempList;
            CHK(autoFormat.sprintf(_T("//def:message[@name=\"%s\"]/def:part[@type]"), bstrPartName));
            hr = _XPATHUtilFindNodeListFromRoot(pOperationNode, &autoFormat, &pTempList);
            if (SUCCEEDED(hr))
            {
                hr = E_INVALIDARG;
                globalAddError(WSDL_IDS_DOCLITERALTOOMANY, WSDL_IDS_OPERATION, hr, bstrPartName);
                goto Cleanup;
              }
            hr = S_OK;
        }
    }
    else if (!m_fIsLiteral && !pParent->isDocumentMode())
    {
        // rpc/encoded again. check if we have any part/element in there
        CAutoRefc<IXMLDOMNodeList> pTempList;

        CHK(autoFormat.sprintf(_T("//def:message[@name=\"%s\"]/def:part[@element]"), bstrPartName));
        hr = _XPATHUtilFindNodeListFromRoot(pOperationNode, &autoFormat, &pTempList);
        if (SUCCEEDED(hr))
        {
            hr = E_INVALIDARG;
            globalAddError(WSDL_IDS_RCPENCODEDWITHELMENT, WSDL_IDS_OPERATION, hr, bstrPartName);
            goto Cleanup;
        }
    }


    // so we did NOT expand a parameters/element, do the normal stuff
    pPart.Clear();
    while (((hr = pNodeList->nextNode(&pPart))==S_OK) && pPart != 0)
    {
        // all of those parts go into a soapmapper...
        pSoapMapper = new CSoapObject<CSoapMapper>(INITIAL_REFERENCE);
        if (!pSoapMapper)
        {
            hr = E_OUTOFMEMORY;
            goto Cleanup;
        }
        hr = pSoapMapper->Init(pPart, ptypeFactory, fInput, bstrNSUri, pParent);
        if (FAILED(hr))
        {
            globalAddError(WSDL_IDS_INITMAPPERFAILED, WSDL_IDS_OPERATION, hr, pchOperationName);
            goto Cleanup;
        }
        CHK(pParent->AddMapper(pSoapMapper, this, fInput, lOrder));

        pPart.Clear();
         release(&pSoapMapper);
        lOrder++;
    }


    hr = S_OK;


Cleanup:
    release(&pSoapMapper);
    release(&pPart);
     ASSERT(hr==S_OK);
    return (hr);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: HRESULT CWSDLMessagePart::AddOrdered(ISoapMapper *pMapper)
//
//  parameters:
//
//  description:
//      adds the mapper to an ordered list for output
//  returns:
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CWSDLMessagePart::AddOrdered(ISoapMapper *pMapper)
{
    return (m_pEnumMappersToSave->AddOrdered(pMapper));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////




/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: HRESULT CWSDLOperation::AddWSMLMetaInfo(IXMLDOMNode *pServiceNode,  CWSDLService *pWSDLService,
//							IXMLDOMDocument *pWSDLDom,  IXMLDOMDocument *pWSMLDom, bool bLoadOnServer)
//
//  parameters:
//
//  description:
//
//  returns:
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CWSDLOperation::AddWSMLMetaInfo(IXMLDOMNode *pPortNode,
                                        CWSDLService *pWSDLService,
                                        IXMLDOMDocument *pWSDLDom,
                                        IXMLDOMDocument *pWSMLDom,
                                        bool bLoadOnServer)
{
    HRESULT         hr = S_OK;

    CAutoRefc<IXMLDOMNode>     pObject=0;
    CAutoRefc<IXMLDOMNode>     pExecute=0;
    CAutoRefc<CSoapMapper>     pSoapMapper=0;
    DWORD                        dwCookie;
    long                           lFetched;
    CAutoFormat                   autoFormat;
    CAutoBSTR                    bstrPortHeaderHandler;
    CAutoBSTR                    bstrOperationHeaderHandler;



    ASSERT(bLoadOnServer ? pPortNode!=0 : true);



    if (bLoadOnServer)
    {
        // first get the subnode

        CHK(autoFormat.sprintf(_T("./operation[@name=\"%s\"]/execute"), m_bstrName));

        _WSDLUtilFindAttribute(pPortNode, g_pwstrHeaderHandlerAttribute, &bstrPortHeaderHandler);


        hr = pPortNode->selectSingleNode(&autoFormat, &pExecute);
        if (hr != S_OK)
        {
            globalAddError(WSML_IDS_OPERATIONNOEXECUTE, WSDL_IDS_OPERATION, hr, m_bstrName);
            hr = E_FAIL;
            goto Cleanup;
        }

        if (pExecute)
        {
            // found the right guy. now get the information

            // check for local headerHandler
            _WSDLUtilFindAttribute(pExecute, g_pwstrHeaderHandlerAttribute, &bstrOperationHeaderHandler);

            // we need the method name
            hr = _WSDLUtilFindAttribute(pExecute, _T("method"), &m_bstrMethodName);
            if (FAILED(hr))
            {
                globalAddError(WSML_IDS_OPERATIONNOMETHODNAME, WSDL_IDS_OPERATION, hr, m_bstrName);
                goto Cleanup;
            }

            // we need the dispid -> faster than dynamic lookup
            {
                CAutoBSTR bstrTemp;

                hr = _WSDLUtilFindAttribute(pExecute, _T("dispID"), &bstrTemp);
                if (SUCCEEDED(hr))
                {
                    // convert the string to a dispid
                    m_dispID = _wtoi(bstrTemp);
                }
                else
                {
                    m_dispID = DISPID_UNKNOWN;
                }
            }


            // now we need the reference to the object used...
            {
                CAutoBSTR bstrTemp;

                hr = _WSDLUtilFindAttribute(pExecute, _T("uses"), &bstrTemp);
                if (FAILED(hr))
                {
                    globalAddError(WSML_IDS_OPERATIONNOUSESATTR, WSDL_IDS_OPERATION, hr, m_bstrName);
                    goto Cleanup;
                }
                // now get the pointer to the dispatchmapper, we can hold on to this guy
                //    as long as the service object lives. which will live as long as we do
                // as we addrefed the guy
                m_pDispatchHolder = pWSDLService->GetDispatchHolder(bstrTemp);
                if (!m_pDispatchHolder)
                {
                    globalAddError(WSML_IDS_OPERATIONINVALIDDISP, WSDL_IDS_OPERATION, hr, m_bstrName);
                    hr = E_INVALIDARG;
                    goto Cleanup;
                }
                m_pDispatchHolder->AddRef();
            }

            // check for valid headerhandler
            m_pHeaderHandler = pWSDLService->GetHeaderHandler(bstrOperationHeaderHandler ? bstrOperationHeaderHandler : bstrPortHeaderHandler);
            if (m_pHeaderHandler)
            {
                m_pHeaderHandler->AddRef();
            }


            // now we have to walk the mappers and let them add their data
            dwCookie = 0;
            while(m_pEnumSoapMappers->getNext((ISoapMapper**)&pSoapMapper, &dwCookie)==S_OK)
            {
                hr = ((CSoapMapper*)pSoapMapper)->AddWSMLMetaInfo(pExecute,
                                                                  pWSDLService,
                                                                  pWSDLDom,
                                                                  pWSMLDom,
                                                                  bLoadOnServer);
                if (FAILED(hr))
                {
                    globalAddError(WSML_IDS_MAPPERINITFAILED, WSDL_IDS_OPERATION, hr, m_bstrName);
                    goto Cleanup;
                }
                release(&pSoapMapper);
            }
            hr =m_pEnumSoapMappers->CountOfArguments((long*)&(lFetched));
            if (FAILED(hr))
            {
                goto Cleanup;
            }
        }
    }
    else
    {
        // on the client just forward to the mappers...
        dwCookie = 0;
        while(m_pEnumSoapMappers->getNext((ISoapMapper**)&pSoapMapper, &dwCookie)==S_OK)
        {
            hr = ((CSoapMapper*)pSoapMapper)->AddWSMLMetaInfo(pExecute,
                                                              pWSDLService,
                                                              pWSDLDom,
                                                              pWSMLDom,
                                                              bLoadOnServer);
            if (FAILED(hr))
            {
                globalAddError(WSML_IDS_MAPPERINITFAILED, WSDL_IDS_OPERATION, hr, m_bstrName);
                goto Cleanup;
            }
            release(&pSoapMapper);
        }

    }



Cleanup:
    ASSERT(hr==S_OK);
    return (hr);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////







/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: HRESULT CWSDLOperation::get_objectProgID(BSTR *pbstrobjecProgID)
//
//  parameters:
//
//  description:
//
//  returns:
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CWSDLOperation::get_objectProgID(BSTR *pbstrobjectProgID)
{
    if (!pbstrobjectProgID)
    {
        return (E_INVALIDARG);
    }
    if (!m_pDispatchHolder)
    {
        // we don't have a dispatch holder
        *pbstrobjectProgID = ::SysAllocString(_T("undefined"));
        if (!*pbstrobjectProgID)
        {
            return(E_OUTOFMEMORY);
        }
        return (S_OK);
    }
    return m_pDispatchHolder->GetProgID(pbstrobjectProgID);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////





/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: HRESULT CWSDLOperation::get_objectMethod(BSTR *pbstrobjectMethod)
//
//  parameters:
//
//  description:
//
//  returns:
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CWSDLOperation::get_objectMethod(BSTR *pbstrobjectMethod)
{
    return _WSDLUtilReturnAutomationBSTR(pbstrobjectMethod, m_bstrMethodName);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////







/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: HRESULT CWSDLOperation::SaveHeaders(ISoapSerializer *pISoapSerializer, VARIANT_BOOL vbInput)
//
//  parameters:
//
//  description:
//
//  returns:
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CWSDLOperation::SaveHeaders(ISoapSerializer *pISoapSerializer, VARIANT_BOOL vbInput)
{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -