【问题标题】:Getting exception while sending soap request from springboot: Invalid Content-Type:text/html. Is this an error message instead of a SOAP response?;从springboot发送soap请求时出现异常:无效的Content-Type:text/html。这是错误消息而不是 SOAP 响应吗?
【发布时间】:2020-01-24 13:39:50
【问题描述】:

我在向第三方应用程序发送肥皂请求时遇到异常,并且在代码中我没有为肥皂请求设置内容类型。

我尝试在 marshalSendAndReceive(..) 之前打印 soap 请求,但我看不到任何打印请求,我认为错误发生在它可以打印/记录请求之前。

需要帮助!!

以下是例外:

.sun.xml.internal.messaging.saaj.soap   : SAAJ0537: Invalid Content-Type. 
Could be an error message instead of a SOAP message
2020-01-22 09:09:42.116 ERROR [cheque- 
service,ca93accf0bdaa764,85d910ae8dabce62,false] 230 --- [0.0-8888-exec-2] 
c.d.i.m.p.c.e.ExceptionLoggerAspect      : Cheque Print service - Unexpected 
error occurred:
org.springframework.ws.soap.SoapMessageCreationException: Could not create message from InputStream: Invalid Content-Type:text/html. Is this an error message instead of a SOAP response?; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Invalid Content-Type:text/html. Is this an error message instead of a SOAP response?
at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:216)
at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:60)
at org.springframework.ws.transport.AbstractWebServiceConnection.receive(AbstractWebServiceConnection.java:92)
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:611)
at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:555)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:383)
at com.deloitte.insurcloud.microservices.payment.chequeservice.service.client.GwApiClient.callGuidewire(GwApiClient.java:43)
at com.deloitte.insurcloud.microservices.payment.chequeservice.service.client.GwApiClient.updateCheckStatus(GwApiClient.java:36)
at com.deloitte.insurcloud.microservices.payment.chequeservice.service.client.GwApiClient$$FastClassBySpringCGLIB$$9966cc9c.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:736)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:84)
at com.deloitte.insurcloud.microservices.payment.chequeservice.exception.ExceptionLoggerAspect.aroundProcessException(ExceptionLoggerAspect.java:26)

【问题讨论】:

    标签: spring-boot web-services soap marshalling


    【解决方案1】:

    Content-Type 的值似乎有误。

    请使用以下示例:

     headers.setContentType(MediaType.TEXT_XML);
    

    注意:text/xml 是 SOAP 1.1 内容类型。

    【讨论】:

      猜你喜欢
      • 2022-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多