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

📄 wsdlport.cpp

📁 Windows CE 6.0 Server 源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        // this is probably NOT a soap binding,
        hr = S_FALSE;
        goto Cleanup;
    }

    hr = _WSDLUtilFindAttribute(pLocation, _T("location"), &m_bstrLocation);
    if (FAILED(hr))
    {
        globalAddError(WSDL_IDS_NOLOCATIONATTR, WSDL_IDS_PORT,hr, m_bstrName);
        goto Cleanup;
    }


    // now find the bindings
    hr = _XPATHUtilFindNodeListFromRoot(pPortNode, _T("//def:binding"), &pNodeList);
    if (FAILED(hr))
    {
        globalAddError(WSDL_IDS_BINDINGSNOTFOUND, WSDL_IDS_PORT,hr, m_bstrName);
        goto Cleanup;
    }

    while (((hr = pNodeList->nextNode(&pBinding))==S_OK) && pBinding != 0)
    {
        // now check the match of the binding names
        bstrTemp.Clear();
        hr = _WSDLUtilFindAttribute(pBinding, _T("name"), &bstrTemp);
        if (FAILED(hr))
        {
            globalAddError(WSDL_IDS_BINDINGSNONAME, WSDL_IDS_PORT,hr, m_bstrName);
            goto Cleanup;
        }

        if (wcscmp(bstrTemp, m_bstrBinding)==0)
        {
            // found the right one
            hr = AnalyzeBinding(pBinding, ptypeFactory);
            if (FAILED(hr))
            {
                globalAddError(WSDL_IDS_ANALYZEBINDINGFAILED, WSDL_IDS_PORT,hr, m_bstrName);
            }
            // exit anyway
            goto Cleanup;
        }
        release(&pBinding);
    }

    // if we arrive here, we did not find the right guy...
    hr = E_FAIL;
    globalAddError(WSDL_IDS_BINDINGSNOTFOUND, WSDL_IDS_PORT,hr, m_bstrName);

Cleanup:
    ASSERT(SUCCEEDED(hr));
    return (hr);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: HRESULT CWSDLPort::AnalyzeBinding(IXMLDOMNode *pBinding, ISoapTypeMapperFactory *ptypeFactory)
//
//  parameters:
//
//  description:
//
//  returns:
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CWSDLPort::AnalyzeBinding(IXMLDOMNode *pBinding, ISoapTypeMapperFactory *ptypeFactory)
{
    HRESULT                     hr = E_FAIL;
    CAutoBSTR                   bstrEncoding;
    CAutoRefc<IXMLDOMNode>         pSoapBinding=0;
    CAutoRefc<IXMLDOMNode>         pOperation=0;
    CAutoRefc<IXMLDOMNode>         pEncodingNode=0;
    CAutoRefc<IXMLDOMNodeList>    pNodeList=0;
    CWSDLOperation                *pWSDLOperation=0;
    long                        lSize=0;
#ifndef UNDER_CE
    BOOL                        fEqual;
#endif 
    BOOL                        bCreateHrefs=false;
    CAutoBSTR                   bstrTemp;


    ASSERT(pBinding!=0);

    // now we need to get the binding information
    // first copy the string over, so that we don't have to parse this again
    hr = _WSDLUtilFindAttribute(pBinding, _T("type"), &bstrTemp);
    if (FAILED(hr))
    {
        globalAddError(WSDL_IDS_BINDINGNOTYPE, WSDL_IDS_PORT,hr, m_bstrName);
        goto Cleanup;
    }
    // remove the optional specifier from the name and copy over
    // now find the start of the binding name
    CHK(_WSDLUtilSplitQName(bstrTemp, 0, &m_bstrPortType));

    hr = pBinding->selectSingleNode(_T("./soap:binding"), &pSoapBinding);
    if (hr != S_OK)
    {
        globalAddError(WSDL_IDS_PORTTYPENOBINDING, WSDL_IDS_PORT,hr, m_bstrName);
        goto Cleanup;
    }

    hr = _WSDLUtilGetStyle(pSoapBinding,&m_fDocumentMode);
    if (FAILED(hr))
    {
        // found no attribute, set the default to document mode
        m_fDocumentMode = true;
        hr = S_OK;
    }

    hr = _WSDLUtilFindAttribute(pSoapBinding, _T("transport"), &m_bstrBindTransport);
    if (FAILED(hr))
    {
        globalAddError(WSDL_IDS_PORTNOTRANSPORT, WSDL_IDS_PORT,hr, m_bstrName);
        goto Cleanup;
    }

    bCreateHrefs = false;
    CHK(_WSDLUtilFindExtensionInfo(pBinding, &bstrEncoding, &bCreateHrefs));

    // now create the operations....


    hr = pBinding->selectNodes(_T("./def:operation"), &pNodeList);
    if (FAILED(hr))
    {
        globalAddError(WSDL_IDS_PORTNOOPERATIONS, WSDL_IDS_PORT,hr, m_bstrName);
        goto Cleanup;
    }

    // create the enum to hold the operations
    m_pOperationsEnum = new CSoapObject<CEnumWSDLOperations>(INITIAL_REFERENCE);

#ifdef UNDER_CE
    if(!m_pOperationsEnum)
    {
       hr = E_OUTOFMEMORY;
       goto Cleanup;
    } 
#endif

    while (((hr = pNodeList->nextNode(&pOperation))==S_OK) && pOperation!=0)
    {
        pWSDLOperation = new CSoapObject<CWSDLOperation>(INITIAL_REFERENCE);

#ifdef UNDER_CE        
        if(!pWSDLOperation)
        {
           hr = E_OUTOFMEMORY;
           goto Cleanup;
        } 
#endif

        hr = pWSDLOperation->Init(pOperation, ptypeFactory, m_bstrPortType, m_fDocumentMode, bstrEncoding, bCreateHrefs);
        if (FAILED(hr))
        {
            globalAddError(WSDL_IDS_PORTOPERATIONINITFAILED, WSDL_IDS_PORT,hr, m_bstrName);
            ((CWSDLOperation*)pWSDLOperation)->Shutdown();
            pWSDLOperation->Release();
            goto Cleanup;
        }
        release(&pOperation);
        m_pOperationsEnum->Add(pWSDLOperation);
        pWSDLOperation->Release();
    }
    if (m_pOperationsEnum->Size(&lSize)==S_OK && lSize>0)
    {
        hr = S_OK;
    }
    else
    {
        globalAddError(WSDL_IDS_PORTNOOPERATIONS, WSDL_IDS_PORT,hr, m_bstrName);
    }



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






/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: HRESULT CWSDLPort::AddWSMLMetaInfo(IXMLDOMNode *pServiceNode,CWSDLService *pWSDLService,
//						IXMLDOMDocument *pWSDLDom, IXMLDOMDocument *pWSMLDom, bool bLoadOnServer)
//
//  parameters:
//
//  description:
//        port has nothing to do, just pass it on....
//  returns:
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CWSDLPort::AddWSMLMetaInfo(IXMLDOMNode *pServiceNode,
                                    CWSDLService *pWSDLService,
                                    IXMLDOMDocument *pWSDLDom,
                                    IXMLDOMDocument *pWSMLDom,
                                    bool bLoadOnServer)
{
    HRESULT                 hr = S_OK;
    long                    lFetched;
    IWSDLOperation            *pWSDLOperation=0;
       CAutoRefc<IXMLDOMNode>     pPortNode=0;
    CAutoFormat             autoFormat;

    ASSERT(m_pOperationsEnum!=0);


    // if we are loading on the client, we don't need to do this.
    //  all we want is forward this to the mappers so that they can check the custom mappers
    // first get the subnode
    //

    if (bLoadOnServer)
    {
        CHK(autoFormat.sprintf(_T("//service[@name=\"%s\"]/port[@name=\"%s\"]"), pWSDLService->getName(), m_bstrName));
        hr = pServiceNode->selectSingleNode(&autoFormat, &pPortNode);
        if (hr != S_OK)
        {
            globalAddError(WSML_IDS_NOPORTTYPE, WSDL_IDS_PORT, hr, m_bstrName);
            hr = E_FAIL;
            goto Cleanup;
        }
    }


    m_pOperationsEnum->Reset();

    while(m_pOperationsEnum->Next(1, &pWSDLOperation, &lFetched)==S_OK)
    {
        hr = ((CWSDLOperation*)pWSDLOperation)->AddWSMLMetaInfo(pPortNode,
                                                pWSDLService,
                                                pWSDLDom,
                                                pWSMLDom,
                                                bLoadOnServer);
        if (FAILED(hr))
        {
            globalAddError(WSML_IDS_OPERATIONINITFAILED, WSDL_IDS_PORT, hr, m_bstrName);
            goto Cleanup;
        }
        release(&pWSDLOperation);
    }
Cleanup:
    release(&pWSDLOperation);
    ASSERT(hr==S_OK);
    return (hr);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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