Microsoft Active Directory 웹 서비스 (10.10.41.0까지)에 연결하기 위해 간단한 Java 클라이언트를 만들려고합니다. Microsoft 문서 (여기 http://msdn.microsoft.com/en-us/library/dd976885.aspx )를 사용 하여 다음 코드를 개발합니다.
String str = "<soapenv:Envelope"
+ " xmlns:wsa=\"http://www.w3.org/2005/08/addressing\""
+ " xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">"
+ " <soapenv:Header>"
+ " <wsa:Action soapenv:mustUnderstand=\"1\">http://10.10.41.0:9389/ActiveDirectory/CustomActions/TopologyManagement/GetVersion</wsa:Action>"
+ " <wsa:MessageID>urn:uuid:680a119e-d421-41f6-8e84-b3d3d8887e49</wsa:MessageID>"
+ " <wsa:ReplyTo>"
+ " <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>"
+ " </wsa:ReplyTo>"
+ " <wsa:To soapenv:mustUnderstand=\"1\">net.tcp://10.10.41.0:9389/ActiveDirectoryWebServices/Windows/TopologyManagement</wsa:To>"
+ " </soapenv:Header>"
+ " <soapenv:Body>"
+ " <GetVersionRequest xmlns=\"http://10.10.41.0:9389/ActiveDirectory/CustomActions\"></GetVersionRequest>"
+ " </soapenv:Body>" + " </soapenv:Envelope>";
...
System.out.println(str);
SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance();
SOAPConnection connection = sfc.createConnection();
InputStream is = new ByteArrayInputStream(str.getBytes());
SOAPMessage request = MessageFactory.newInstance().createMessage(null, is);
request.removeAllAttachments();
SOAPPart part = request.getSOAPPart();
part.detachNode();
SOAPEnvelope env = part.getEnvelope();
env.detachNode();
SOAPBody body = env.getBody();
body.detachNode();
SOAPHeader head = env.getHeader();
head.detachNode();
request.writeTo(System.out);
URL endpoint = new URL("http://10.10.41.0:9389");
SOAPMessage response = connection.call(request, endpoint);
System.out.println(response.getContentDescription());
프로그램이 다음 오류와 함께 충돌합니다.
17-dic-2013 10.26.12 com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl createEnvelopeFromSource
GRAVE: SAAJ0304: InputStream does not represent a valid SOAP 1.1 Message
javax.xml.soap.SOAPException: InputStream does not represent a valid SOAP 1.1 Message
at com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelopeFromSource(SOAPPart1_1Impl.java:75)
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:122)
at TCPClient.main(TCPClient.java:52)
SOAP 메시지는 1.2이므로 이것은 나를 위해 일했습니다.
SOAPMessage message = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL)
.createMessage(null, new StringBufferInputStream(xml));
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다