요청 메시지를 보내기 위해 SOAP 클라이언트를 작성해야합니다. 요청을 성공적으로 보낼 수 있지만 메시지를 수정해야합니다. 필요한 수정은 하위 요소에 접두사를 추가하는 것뿐입니다. 다음 코드를 사용했지만 아무 일도 일어나지 않습니다.
WebsiteConfigID.addNamespaceDeclaration("v3", "http://tnwebservices.ticketnetwork.com/tnwebservice/v3.2");
전류 출력
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
xmlns:v3="http://tnwebservices.ticketnetwork.com/tnwebservice/v3.2">
<env:Header/>
<env:Body>
<GetEvents>
<websiteConfigID>1111</websiteConfigID>
<cityZip>Paris</cityZip>
</GetEvents>
</env:Body>
</env:Envelope>
예상 출력
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
xmlns:v3="http://tnwebservices.ticketnetwork.com/tnwebservice/v3.2">
<env:Header/>
<env:Body>
<v3:GetEvents> <<prefix is added
<v3:websiteConfigID>1111</v3:websiteConfigID> <<prefix is added
<v3:cityZip>Paris</v3:cityZip> <<prefix is added
</v3:GetEvents>
</env:Body>
</env:Envelope>
암호
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = soapConnectionFactory.createConnection();
SOAPMessage message = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL).createMessage();
SOAPBody body = message.getSOAPBody();
SOAPPart part = message.getSOAPPart();
SOAPEnvelope envelope = part.getEnvelope();
envelope.addNamespaceDeclaration("v3", "http://tnwebservices.ticketnetwork.com/tnwebservice/v3.2");
SOAPFactory soapFactory = SOAPFactory.newInstance();
Name bodyName;
bodyName = soapFactory.createName("GetEvents");
SOAPBodyElement getEvents = body.addBodyElement(bodyName);
Name childName = soapFactory.createName("websiteConfigID");
SOAPElement WebsiteConfigID = getEvents.addChildElement(childName);
WebsiteConfigID.addTextNode("1111");
childName = soapFactory.createName("cityZip");
SOAPElement CityZip = getEvents.addChildElement(childName);
CityZip.addTextNode("Paris");
message.writeTo(System.out);
, 또는 접두사 및 uri 정보 SOAPFactory
를 취하는 방법을 사용 QName
하십시오. 예를 들어, 호출하는 대신 bodyName = soapFactory.createName("GetEvents");
, 그것은해야
bodyName = soapFactory.createName("GetEvents", "v3",
"http://tnwebservices.ticketnetwork.com/tnwebservice/v3.2");
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다