Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为SpringWebServiceTemplate指定SOAP请求负载的正确方法是什么?_Java_Spring_Soap_Wsdl - Fatal编程技术网

Java 为SpringWebServiceTemplate指定SOAP请求负载的正确方法是什么?

Java 为SpringWebServiceTemplate指定SOAP请求负载的正确方法是什么?,java,spring,soap,wsdl,Java,Spring,Soap,Wsdl,我有点困了。我有一个用于生成Java存根的WSDL(使用maven-jaxb2-plugin)。它已经为响应生成了对象,但是没有为请求生成对象。看看WSDL,我猜这是因为请求“简单” 摘录: <message name='getImagesRequest'> <part name='Type' type='xsd:string'/> <part name='Code' type='xsd:string'/> </message> 然而

我有点困了。我有一个用于生成Java存根的WSDL(使用maven-jaxb2-plugin)。它已经为响应生成了对象,但是没有为请求生成对象。看看WSDL,我猜这是因为请求“简单”

摘录:

<message name='getImagesRequest'>
 <part name='Type' type='xsd:string'/>
 <part name='Code' type='xsd:string'/>    
</message>
然而,这一切都失败了,出现了一个毫无帮助的错误:“根元素后面的文档中的标记必须格式良好。”

有人能告诉我正确设置有效载荷的方向吗?因为我觉得我偏离了目标


谢谢

jaxb2插件不使用您的wsdl,它只使用xsd,因此如果您的类型不在其中,它将不会生成任何内容。您可能想尝试使用jax ws插件来生成对象。真的吗?即使使用WSDL?谢谢,我将尝试jax-ws!一点也不。但是也许事情已经改变了…。@M.Deinum:看起来你应该可以做我正在做的事情。然而,你是对的,很有可能发生的只是我的xsd被拾取,而不是我的wsdl。谢谢:)
    String request = "<Type>" + inKey.getType() + "</Type>" +                         
                     "<Code>" + inKey.getCode() + "</Code>";

    StreamSource requestPayload = new StreamSource(new StringReader(request));

    WebServiceMessageCallback requestCallback = new WebServiceMessageCallback() {
        @Override
        public void doWithMessage(WebServiceMessage inMessage) throws IOException, TransformerException
        {
            ((SoapMessage) inMessage).setSoapAction("/getImagesRequest");
        }
    };

    SourceExtractor<SupplierList> responseExtractor = new SourceExtractor<SupplierList>() {
        @Override
        public SupplierList extractData(Source inSource) throws IOException, TransformerException
        {
            return (SupplierList) (getWebServiceTemplate().getUnmarshaller().unmarshal(inSource));
        }
    };

    SupplierList response = (SupplierList) getWebServiceTemplate().sendSourceAndReceive(requestPayload, requestCallback, responseExtractor);