2013-07-04 2 views
0

이 내가 서비스로 보낼 싶어 봉투입니다 :추가 네임 스페이스 접두사 Axis2를

<?xml version='1.0' encoding='utf-8'?> 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soapenv:Body xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> 
     <sear:searchUrls> 
      <sear:in0>Safeway, 200 S. 3rd St, Renton, WA</sear:in0> 
     </sear:searchUrls> 
    </soapenv:Body> 
</soapenv:Envelope> 

을 그리고 이것은 그것을 구성하는 코드입니다

SOAPFactory fac = OMAbstractFactory.getSOAP12Factory(); 
SOAPEnvelope envelope = fac.getDefaultEnvelope(); 

OMNamespace omNs = fac.createOMNamespace("http://schemas.xmlsoap.org/soap/envelope/", "soapenv"); 
OMNamespace ns1 = fac.createOMNamespace("http://search", "sear"); 

envelope.setNamespace(omNs); 

OMNamespace ns = fac.createOMNamespace("", "") 
OMElement method = fac.createOMElement("sear:searchUrls", ns); 
OMElement value = fac.createOMElement("sear:in0", ns); 
value.setText("Safeway, 200 S. 3rd St, Renton, WA"); 
method.addChild(value); 
envelope.getBody().addChild(method); 

을 그러나 "시든"내 네임 스페이스 접두사가 정의되어 있지 . 어떻게 XML에서

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sear="http://search"> 

를 얻기 위해 코드를 설정할 수 있습니까?

+0

에서

자세한 정보는 당신이 서비스에 보낼 것을 보여주기 위해 가정되는 XML 조각을 검토 할 필요가있다. SOAP 1.1과 SOAP 1.2를 섞어 놓았으며'sear' 접두어에 대한 네임 스페이스 선언이 없습니다. 따라서 그것은 유효하지 않습니다. 스 니펫은 생성하려는 메시지가 아닌 코드의 실제 출력을 보여줍니다. –

답변

1
envelope.addNamespaceDeclaration("sear", "http://search"); 
+0

'addNamespaceDeclaration()'메소드가 존재하지 않습니다. 대신에'envelope.declareNamespace ("URI", "Prefix")'를 사용하십시오. – vkrams

관련 문제