ISOAPNamespaces::GetPrefixForURI Method

HRESULT GetPrefixForURI([in] BSTR NamespaceURI, [out, retval] BSTR * prefix);

This will search the currently active namespaces for the specified namespace URI, and return its current prefix. If not found it will create a new prefix and add it as an active namespace. Typically you don't need to call this, as the methods on the ISerializerOutput interface all take namespace URI's and handle the prefix mappings for you.

 

Parameters

NamespaceURI
BSTR, [in]: The namespace URI e.g. urn:xmethods-delayed-quotes or http://soapinterop.org/xsd
prefix
BSTR *, [out, retval]: This returns the prefix associated with the URI

 

Return Values

The results prefix for this namespace

 

Sample Code

STDMETHODIMP CMySerializer::Serialize( /*[in]*/ VARIANT *val, ISerializerContext * ctx, /*[in]*/ ISerializerOutput * dest )
{
	if ( val->vt != VT_BSTR ) return E_UNEXPECTED ;
	CComPtr n ;
	ctx->get_Namespaces(&n) ;
	CComBSTR prefix ;
	ctx->GetPrefixForURI ( CComBSTR(L"http://schemas.pocketsoap.com/samples/"), &prefix ) ;
	dest->WriteText(prefix) ;
	dest->WriteText(CComBSTR(L":")) ;
	dest->WriteText(val->bstrVal) ;
	return ;
}

 

See Also

The ISOAPNamespaces Interface | 

 

 

Copyright

Copyright © Simon Fell, 2000-2004. All rights reserved.