WSDL을 사용하여 SOAP 클라이언트를 작성하고 있습니다. 나는 PHP에서 비슷한 코드를 가지고있다. 그러나 Java에서 몇 가지 문제가 있습니다. 다음은 내 코드 단편입니다.WSDL을 사용하는 SOAP 클라이언트
로컬 WSDL 파일의 경로는 어디에 정의해야합니까?
모든 아이디어를 환영합니다.
2014년 11월 3일 오후 4시 18분 27초 com.sun.xml.internal.messaging.saaj.soap :
try { SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection soapConnection = soapConnectionFactory.createConnection(); SOAPMessage soapResponse = soapConnection.call(mySampleQuery(), "https://www.webpagename.com"); // Process the SOAP Response printSOAPResponse(soapResponse); soapConnection.close(); } catch (Exception e) { System.err.println("Error occurred while sending SOAP Request to Server"); e.printStackTrace(); } private static SOAPMessage queryFlightsByAerodrome() throws Exception { MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); String serverURI = "localfolder/wsdlfilename.wsdl"; // SOAP Envelope SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration("mydata", serverURI); // SOAP Body SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody.addChildElement("mySampleRequest", "mydata"); SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("userId"); soapBodyElem1.addTextNode("testuser"); //...here I create soapBodyElem1 MimeHeaders headers = soapMessage.getMimeHeaders(); headers.addHeader("SOAPAction", serverURI + "queryTestData"); System.out.println("Content description: "+soapMessage.getContentDescription()); soapMessage.saveChanges(); /* Print the request message */ System.out.print("Request SOAP Message:"); soapMessage.writeTo(System.out); System.out.println(); return soapMessage; }
I 라인
SOAPMessage soapResponse = soapConnection.call(mySampleQuery(),"https://www.webpagename.com")
에서 다음과 같은 오류가이 코드를 실행 한 후 .MessageImpl identifyContentType SEVERE : SAAJ0537 : 유효하지 않은 Content-Type. SOAP 메시지 대신 오류 메시지가 발생 함 서버에 SOAP 요청을 보내는 중에 오류가 발생했습니다. com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl : com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl : 올바르지 않습니다. Content-Type : text/html 이 메시지가 SOAP 응답 대신 오류 메시지입니까? com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call (알 수 없음 소스) com.aslogic.isagent.MyAgent.main (MyAgent.java:46) 발생 원인 : com.sun .xml.internal.messaging.saaj.SOAPExceptionImpl : 잘못된 내용 유형 : text/html. SOAP 응답 대신 오류 메시지입니까? 에서 com.sun.xml.internal.messaging.saaj.soap.MessageFactoryImpl.createMessage에서 com.sun.xml.internal.messaging.saaj.soap.MessageImpl.identifyContentType (알 소스) (알 소스)에서 com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post (알 소스)
당신에게 확인 서비스 URL이 정확한지 있습니다 어떻게 든
관련 클라이언트 안타 모든 로그인 들여다? 브라우저로 확인 무엇의 반환 – JIV
@JIV : 내가 언급 한 바와 같이, 내가 PHP에서 비슷한 코드를 가지고 있고 그것을 잘 작동합니다. 따라서 서비스 URL이 정확하다는 의미입니다. 그러나 PHP에서는 WSDL 파일과 인증서 파일의 경로를 정의합니다. Java에서이 작업을 수행하는 방법을 모르겠습니다. –
사실 난 당신이 어쩌면 당신은 이상한 것은이 – JIV