• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java NamespaceContextImpl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.ws.commons.util.NamespaceContextImpl的典型用法代码示例。如果您正苦于以下问题:Java NamespaceContextImpl类的具体用法?Java NamespaceContextImpl怎么用?Java NamespaceContextImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NamespaceContextImpl类属于org.apache.ws.commons.util包,在下文中一共展示了NamespaceContextImpl类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: unwrapSoapMessage

import org.apache.ws.commons.util.NamespaceContextImpl; //导入依赖的package包/类
public Element unwrapSoapMessage(Element soapElement) {
    XPath xpath = XPathFactory.newInstance().newXPath();
    NamespaceContextImpl context = new NamespaceContextImpl();
    context.startPrefixMapping("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
    context.startPrefixMapping("samlp", "urn:oasis:names:tc:SAML:2.0:protocol");
    context.startPrefixMapping("saml", "urn:oasis:names:tc:SAML:2.0:assertion");
    context.startPrefixMapping("ds", "http://www.w3.org/2000/09/xmldsig#");
    xpath.setNamespaceContext(context);
    try {
        final String expression = "/soapenv:Envelope/soapenv:Body/samlp:Response";
        Element element = (Element) xpath.evaluate(expression, soapElement, XPathConstants.NODE);

        if (element == null) {
            String errorMessage = format("Document{0}{1}{0}does not have element {2} inside it.", NEW_LINE,
                    writeToString(soapElement), expression);
            LOG.error(errorMessage);
            throw new IllegalArgumentException(errorMessage);
        }

        return element;
    } catch (XPathExpressionException e) {
        throw propagate(e);
    }
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:25,代码来源:SoapMessageManager.java


示例2: unwrapSoapMessage

import org.apache.ws.commons.util.NamespaceContextImpl; //导入依赖的package包/类
private Element unwrapSoapMessage(Element soapElement, SamlElementType samlElementType) {
    XPath xpath = XPathFactory.newInstance().newXPath();
    NamespaceContextImpl context = new NamespaceContextImpl();
    context.startPrefixMapping("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
    context.startPrefixMapping("samlp", "urn:oasis:names:tc:SAML:2.0:protocol");
    context.startPrefixMapping("saml", "urn:oasis:names:tc:SAML:2.0:assertion");
    context.startPrefixMapping("ds", "http://www.w3.org/2000/09/xmldsig#");
    xpath.setNamespaceContext(context);
    try {
        String expression = "//samlp:" + samlElementType.getElementName();
        Element element = (Element) xpath.evaluate(expression, soapElement, XPathConstants.NODE);

        if (element == null) {
            String errorMessage = format("Document{0}{1}{0}does not have element {2} inside it.", NEW_LINE,
                    XmlUtils.writeToString(soapElement), expression);
            LOG.error(errorMessage);
            throw new SoapUnwrappingException(errorMessage);
        }

        return element;
    } catch (XPathExpressionException e) {
        throw propagate(e);
    }
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:25,代码来源:SoapMessageManager.java


示例3: getParser

import org.apache.ws.commons.util.NamespaceContextImpl; //导入依赖的package包/类
@Override
public TypeParser getParser(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, String pURI, String pLocalName) {
    TypeParser defaultParser = super.getParser(pConfig, pContext, pURI, pLocalName);
    if (defaultParser instanceof I4Parser) {
        return new TolerantI4Parser();
    } else if (defaultParser instanceof DateParser) {
        return new TolerantDateParser(new XmlRpcDateTimeDateFormat(){
            private static final long serialVersionUID = 7585237706442299067L;
            protected TimeZone getTimeZone() {
                return getController().getConfig().getTimeZone();
            }
        });
    } else {
        return defaultParser;
    }
}
 
开发者ID:vmware,项目名称:workflowTools,代码行数:17,代码来源:TolerantTypeFactory.java


示例4: IteratorForFedora3

import org.apache.ws.commons.util.NamespaceContextImpl; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param id      the fedora pid of the root object
 * @param client  the jersey client to use
 * @param restUrl the url to Fedora
 * @param filter  the fedora tree filter to know which relations and datastreams to use
 */
public IteratorForFedora3(String id, Client client, String restUrl, FedoraTreeFilter filter,
                          String dataFilePattern) {
    super(id, dataFilePattern);
    this.client = client;
    if (!restUrl.endsWith(OBJECTS)) {
        restUrl = restUrl + OBJECTS;
    }
    this.restUrl = restUrl;
    this.filter = filter;
    try {
        XPath xPath = XPATH_FACTORY.newXPath();
        NamespaceContextImpl context = new NamespaceContextImpl();
        context.startPrefixMapping("dc", DC_NAMESPACE);
        context.startPrefixMapping("dp", DATASTREAM_PROFILE_NAMESPACE);
        xPath.setNamespaceContext(context);
        datastreamsXpath = xPath.compile("//@dsid");
        dcIdentifierXpath = xPath.compile("//dc:identifier");
        datastreamChecksumXpath = xPath.compile("//dp:dsChecksum");
        datastreamNameXpath = xPath.compile("/dp:datastreamProfile/dp:dsAltID");

    } catch (XPathExpressionException e) {
        throw new RuntimeException("Illegal XPath. This is a programming error.", e);
    }
    this.name = getNameFromId(id);
}
 
开发者ID:statsbiblioteket,项目名称:newspaper-batch-event-framework,代码行数:34,代码来源:IteratorForFedora3.java


示例5: namespaceContextForSaml

import org.apache.ws.commons.util.NamespaceContextImpl; //导入依赖的package包/类
private NamespaceContext namespaceContextForSaml() {
    NamespaceContextImpl context = new NamespaceContextImpl();
    context.startPrefixMapping("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
    context.startPrefixMapping("saml2p", "urn:oasis:names:tc:SAML:2.0:protocol");
    context.startPrefixMapping("saml2", "urn:oasis:names:tc:SAML:2.0:assertion");
    context.startPrefixMapping("ds", "http://www.w3.org/2000/09/xmldsig#");
    return context;
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:9,代码来源:MatchingServiceHealthCheckIntegrationTests.java


示例6: getAttributeQuery

import org.apache.ws.commons.util.NamespaceContextImpl; //导入依赖的package包/类
private Element getAttributeQuery(Document document) throws XPathExpressionException {
    XPath xpath = XPathFactory.newInstance().newXPath();
    NamespaceContextImpl context = new NamespaceContextImpl();
    context.startPrefixMapping("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
    context.startPrefixMapping("samlp", "urn:oasis:names:tc:SAML:2.0:protocol");
    xpath.setNamespaceContext(context);

    return (Element) xpath.evaluate("//samlp:Response", document, XPathConstants.NODE);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:10,代码来源:SoapMessageManagerTest.java


示例7: getParser

import org.apache.ws.commons.util.NamespaceContextImpl; //导入依赖的package包/类
@Override
public TypeParser getParser(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, String pURI, String pLocalName) {
  if (DoubleSerializer.DOUBLE_TAG.equals(pLocalName)) {
    return new AnalysisRpcDoubleParser();
  }
  return super.getParser(pConfig, pContext, pURI, pLocalName);
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:8,代码来源:AnalysisRpcTypeFactoryImpl.java


示例8: getParser

import org.apache.ws.commons.util.NamespaceContextImpl; //导入依赖的package包/类
/**
 * Correctly handle XML-RPC "None" elements in incoming responses from server.
 */
@Override
public TypeParser getParser(XmlRpcStreamConfig pConfig,
                            NamespaceContextImpl pContext, String pURI, String pLocalName) {

    if ("".equals(pURI) && NullSerializer.NIL_TAG.equals(pLocalName)) {
        return new NullParser();
    } else {
        return super.getParser(pConfig, pContext, pURI, pLocalName);
    }
}
 
开发者ID:vtunka,项目名称:jenkins-koji-plugin,代码行数:14,代码来源:MyTypeFactory.java


示例9: getParser

import org.apache.ws.commons.util.NamespaceContextImpl; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public TypeParser getParser(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, String pURI,
	String pLocalName) {
	if (EObjectSerializer.EOBJECT_TAG.equals(pLocalName)) {
		return new EObjectTypeParser();
	} else {
		return super.getParser(pConfig, pContext, pURI, pLocalName);
	}
}
 
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:13,代码来源:EObjectTypeFactory.java


示例10: getParser

import org.apache.ws.commons.util.NamespaceContextImpl; //导入依赖的package包/类
/**
 * Date parser.
 */
@Override
public TypeParser getParser(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, String pURI, String pLocalName)
{
	if (DateSerializer.DATE_TAG.equals(pLocalName))
	{
		return new DateParser(newFormat());
	}
	return super.getParser(pConfig, pContext, pURI, pLocalName);
}
 
开发者ID:unistra,项目名称:fsp,代码行数:13,代码来源:XmlRpc.java


示例11: getParser

import org.apache.ws.commons.util.NamespaceContextImpl; //导入依赖的package包/类
@Override
public TypeParser getParser(XmlRpcStreamConfig pConfig,
        NamespaceContextImpl pContext, String pURI, String pLocalName) {
    if ("".equals(pURI) && NullSerializer.NIL_TAG.equals(pLocalName)) {
        return new NullParser();
    } else if ("i8".equals(pLocalName)) {
        return new LongTypeParser();
    } else {
        return super.getParser(pConfig, pContext, pURI, pLocalName);
    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:12,代码来源:RpcTypeFactory.java


示例12: parseResponse

import org.apache.ws.commons.util.NamespaceContextImpl; //导入依赖的package包/类
public static List<WebSearchResult> parseResponse(String response) throws ParserConfigurationException, IOException, SAXException, XPathExpressionException {
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      dbf.setNamespaceAware(true);
      DocumentBuilder db = dbf.newDocumentBuilder();

      StringReader reader = new StringReader(response);
      InputSource inputSource = new InputSource(reader);
      Document doc = db.parse(inputSource);

      XPathFactory factory = XPathFactory.newInstance();
      XPath xpath = factory.newXPath();

      NamespaceContextImpl ctx = new NamespaceContextImpl();

/*
       * Prefix mapping for the following XML root tag:
 *
 * <feed xmlns:base="https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/v1/Web"
 * xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
 * xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
 *
 * NOTE: the default namespace can use any prefix, not necessarily default.
 * Yet, exactly the same prefix should also be used in XPATH expressions
 */
      ctx.startPrefixMapping("base", "https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/Web");
      ctx.startPrefixMapping("d", "http://schemas.microsoft.com/ado/2007/08/dataservices");
      ctx.startPrefixMapping("m", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
      ctx.startPrefixMapping("default", "http://www.w3.org/2005/Atom");
      xpath.setNamespaceContext(ctx);

      NodeList nodes = (NodeList) xpath.evaluate("/default:feed/default:entry", doc,
              XPathConstants.NODESET);
      List<WebSearchResult> resultList = new ArrayList<>();
      for (int i = 0; i < nodes.getLength(); i++) {
          try {
              Node CurrNode = nodes.item(i);
              String title = (String) xpath.evaluate("default:content/m:properties/d:Title/text()", CurrNode,
                      XPathConstants.STRING);
              String desc = (String) xpath.evaluate("default:content/m:properties/d:Description/text()", CurrNode,
                      XPathConstants.STRING);
              String url = (String) xpath.evaluate("default:content/m:properties/d:Url/text()", CurrNode,
                      XPathConstants.STRING);

              if (!title.isEmpty() || !desc.isEmpty()) {
                  WebSearchResult res = new WebSearchResult(i, url, title, desc);
                  resultList.add(res);
              }
          } catch (XPathExpressionException e) {
              System.err.printf("[ERROR] cannot parse element # %d, ignoring, error: %s\n",
                      i + 1, e.toString());
          }
      }

      if (VERBOSE)
          System.out.println("Bing reply size: " + resultList.size());
      return resultList;
  }
 
开发者ID:oaqa,项目名称:LiveQA,代码行数:58,代码来源:BingSearch.java



注:本文中的org.apache.ws.commons.util.NamespaceContextImpl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SerializedExceptionProto类代码示例发布时间:2022-05-22
下一篇:
Java ID3v23Tag类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap