2013-03-14 3 views
0

없이 접두사이 내가 원하는 무엇인가 :SOAP 네임 스페이스

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tps="http://mysite.it"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <tps:getBook> 
     <tps:id>45</tps:id> 
     </tps:Retrieve_getBook_Poi_Recordset> 
    </soapenv:Body> 
</soapenv:Envelope> 

을하지만 내가 가진 것입니다 : 내가 javax.xml.soap의를 사용하고

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tps="http://mysite.it"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <tps:getBook xmlns:tps="http://mysite.it"> 
     <tps:id xmlns:tps="http://mysite.it">45</tps:id> 
     </tps:Retrieve_getBook_Poi_Recordset> 
    </soapenv:Body> 
</soapenv:Envelope> 

* SOAP 메시지를 만들 수 있습니다.. .. 그리고 param 태그에 접두어 만 삽입하는 메서드를 찾을 수 없습니다.

이 SOAP 메시지를 생성하는 코드는 다음과 같습니다

MessageFactory msgFactory = null; 
SOAPMessage message = null; 
msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); 
message = msgFactory.createMessage(); 
SOAPEnvelope messageEnvelope = message.getSOAPPart().getEnvelope(); 
SOAPBody messageBody = messageEnvelope.getBody(); 

messageEnvelope.addNamespaceDeclaration(PREFIX, getNameSpace(method)); 

SOAPElement soapMethod = messageBody.addChildElement(method, PREFIX); 
SOAPElement param = soapMethod.addChildElement("id",PREFIX); 
param.addTextNode("45"); 

난 단지 네임 스페이스를 제거하기 위해 무엇을 할 수 있는가?

요소 및 속성 노드에 대한
+0

게시 한 XML 형식이 올바르지 않습니다. 어쨌든 _messageBody.addChildElement (method, PREFIX); _를 _messageBody.addChildElement (envelope.createName (method, PREFIX, getNameSpace (method)));로 대체하십시오 _ –

+0

도움을 주셔서 감사합니다 ... mhhmh..na !. ...그것은 동일합니다 -_-'.... – Ging3r

답변

1

:

Node node = ...; 
String name = node.getLocalName(); 

당신에게 노드 이름의 로컬 부분을 줄 것이다.

앞서 언급했듯이 XML에서 네임 스페이스 정보를 제외하고 싶지는 않습니다. 이것은 당신의 특별한 경우에 대한 좋은 해결 방법이지만, 나는 네임 스페이스 정보를 그대로 남겨 둘 것입니다.