2009-07-21 2 views
0

비누 응답에서 연산 이름과 네임 스페이스를 찾기위한 일반 템플릿을 작성해야합니다. 일반적인 말은 모든 작업에 적용 가능하다는 의미입니다. 따라서 작업 이름과 이름 공간 이름을 알지 못하지만 응답을 보내면 다시 가져오고 수정하려고합니다.XPATH 문에 대한 쿼리

타입 1 : 여기

응답의 구조 조작 스페이스가 <soapenv:Envelope>에 정의되어

<soapenv:Envelope 
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:inf="http://bad.com/abc/infrastructure" 
    xmlns:ret="http://bad.com/FirstOperationToExecute" 
    xmlns:com="http://bad.com/commercial"> 
    <soapenv:Header/> 
    <soapenv:Body> 
    <ret:retrieveSummaryRequest> 
     <!-- ... result ... --> 
    </ret:retrieveSummaryRequest> 
    </soapenv:Body> 
</soapenv:Envelope> 

유형 2 :

<soapenv:Envelope 
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:inf="http://bad.com/abc/infrastructure" 
    xmlns:ret="http://bad.com/FirstOperationToExecute" 
    xmlns:com="http://bad.com/commercial"> 
    <soapenv:Header/> 
    <soapenv:Body> 
    <ret:retrieveSummaryRequest xmlns:ret="http://bad.com/FirstOperationToExecute" > 
     <!-- ... result ... --> 
    </ret:retrieveSummaryRequest> 
    </soapenv:Body> 
</soapenv:Envelope> 
: 요소 <ret:retrieveSummaryRequest> 정의 네임

유형 3 : 기본 네임 스페이스는 <retrieveSummaryRequest> :

<soapenv:Envelope 
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:inf="http://bad.com/abc/infrastructure" 
    xmlns:ret="http://bad.com/FirstOperationToExecute" 
    xmlns:com="http://bad.com/commercial"> 
    <soapenv:Header/> 
    <soapenv:Body> 
    <retrieveSummaryRequest xmlns="http://bad.com/FirstOperationToExecute" > 
     <!-- ... result ... --> 
    </retrieveSummaryRequest> 
    </soapenv:Body> 
</soapenv:Envelope> 

조작 이름과 네임 스페이스를 가져 오는 간단한 XPath 문이 있는지 알려줄 수 있습니까?

답변

0

위의 XML 샘플은 모두 동일한 infoset을 나타냅니다. 그들은 동등한이며, 모든 것이 고려됩니다. 차이점은 직렬화 된 (텍스트) 양식에만 영향을 미치므로 문제가되지 않아야합니다. 내가 바로 당신을 이해한다면

, 당신은이 두 값을 검색하려면 :

  • "http://bad.com/FirstOperationToExecute"
  • "FirstOperationToExecute"

는 XSLT에서이 값 잡아하려면 사용 :

<xsl:template match="ret:retrieveSummaryRequest"> 
    <!-- the full URI --> 
    <xsl:value-of select="namespace-uri()" /> 

    <!-- the operation name only --> 
    <xsl:value-of select=" 
    substring-after(
     substring-after(namespace-uri(), '//'), 
     '/' 
    ) 
    " /> 
</xsl:template> 

XSLT에 없으면 작업 na 검색 나는 올바른 노드를 선택하고 DOM에 네임 스페이스 URI를 묻는 문제이다. 의사 코드 :

dom.registerNSPrefix("soapenv", "http://schemas.xmlsoap.org/soap/envelope/"); 
ret = dom.selectSingleNode("/soapenv:Envelope/soapenv:Body/*[1]"); 
nsUri = ret.namespaceURI; 
opName = nsUri.replace(".*/", ""); // whatever