0
SAAJ를 사용하여 SAOP API에 액세스하려고합니다. SOAP 요청 본문 작성시 다른 답변과 동일한 코드를 사용했으며 SOAP API를 호출하는 경우 을 사용했습니다. 이 특정 서비스는 (API 문서에서 언급 한) 인증을 필요로하지 않으며 입력 매개 변수를 사용하지 않습니다.Java에서 SAAJ API를 사용하는 콘텐츠 형식 오류가 잘못되었습니다.
From WSDL: (copied only relevant content)
<xs:complexType name="getCustomerNames">
<xs:sequence/>
</xs:complexType>
...
<wsdl:operation name="getCustomerNames">
<wsdl:input message="tns:getCustomerNames" name="getCustomerNames"/>
<wsdl:output message="tns:getCustomerNamesResponse" name="getCustomerNamesResponse"/>
<wsdl:fault message="tns:SOAPException" name="SOAPException"/>
</wsdl:operation>
다음은 비누 몸을 만들고 내가 이것을 실행할 때마다 나는 아래의 오류 메시지가 API를
SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
SOAPConnection connection = scf.createConnection();
SOAPFactory sf = SOAPFactory.newInstance();
String serverURI = "com.webservices.services.authentication";
MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); // I tried without parameters as well
SOAPMessage message = mf.createMessage();
message.getSOAPHeader().detachNode();
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
envelope.addNamespaceDeclaration("auth", serverURI);
Name bodyName = sf.createName("getCustomerNames", "auth", serverURI);
SOAPBodyElement bodyElement = body.addBodyElement(bodyName);
URL endpoint = new URL(urlendpoint); // urlendpoint is the one that I took from WSDL file service endpoint.
SOAPMessage response = connection.call(message, endpoint);
connection.close();
를 호출하는 자바 코드입니다. 이유를 이해할 수 없습니다. 동일한 URL이 Unix에서 curl 명령을 실행하고 위의 Java 코드로 작성된 동일한 요청 XML을 게시 할 때 응답을 반환하고 있습니다.
Feb 14, 2017 3:21:54 PM com.sun.xml.internal.messaging.saaj.soap.MessageImpl identifyContentType
SEVERE: SAAJ0537: Invalid Content-Type. Could be an error message instead of a SOAP message
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Invalid Content-Type:text/html. Is this an error message instead of a SOAP response?
제안 해 주셔서 감사합니다. Java 및 API 작업에 익숙하지 않습니다. HTML 응답으로 메시지를받는 방법을 알려주십시오. 현재 SOAPMessage 객체 유형으로 Connection.call()의 출력을 받고 있습니다. 이걸 어떻게 바꾸어야합니까? – Aandal
동일한 요청 XML을 사용하여 curl 명령을 사용할 때 아래 응답이 표시됩니다. 아래 응답은 비누를 말합니다, 그렇지 않습니까? <비누 : 봉투의 xmlns : 비누 = "http://schemas.xmlsoap.org/soap/envelope/"> 예 soap : Envelope> –
Aandal
Wireshark와 같은 것을 사용하여 응답을 가로 챌 수 있습니다. –