SOAP Web服务的XML响应格式

问题描述 投票:0回答:1

嗨,我想创建在谷歌应用程序引擎SOAP Web服务我下面这个article

本教程是呈现出简单的Hello World教程中,我运行这个程序,并成功得到响应

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns3:sayHelloResponse xmlns:ns3="http://example.com/">
<return>Hello, hello!</return>
</ns3:sayHelloResponse>
</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

这是SOAP1.1格式我得1.2格式像SOAP响应

<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
xmlns:e="http://[app-id].appspot.com/gevents-service">
<env:Body>
</env:Body>

为此,我增加一个行上Greeter类的顶部:

@BindingType(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING) 

,然后在Greeter类运行WSGEN命令:

C:\Users\Lenovo\workspace\HelloSoapServer1>wsgen -extension -wsdl:Xsoap1.2 -cp "
./war/WEB-INF/classes" -wsdl -keep -r "./war" -d "./war/WEB-INF/classes" -s "./s
rc" com.example.Greeter

其中HelloSoapServer1是项目名称,它SOAP1.2格式的成功创建wsdl文件,然后我再部署它的AppEngine我期待响应输出在SOAP1.2版本,但仍然反应是一样的previous.here是一些代码

Greeter类

package com.example;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.ws.BindingType;

@WebService
@BindingType(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)
public class Greeter {
  @WebMethod
  public String sayHello(String name){
    return "Hello, " + name+ "!";
  }
  @WebMethod
  public String sayGoodbye(String name){
    return "Goodbye, " + name + "!";
  }
}

生成GreeterService.wsdl代码

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. -->
<definitions targetNamespace="http://example.com/" name="GreeterService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://example.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/">
  <types>
    <xsd:schema>
      <xsd:import namespace="http://example.com/" schemaLocation="GreeterService_schema1.xsd"/>
    </xsd:schema>
  </types>
  <message name="sayHello">
    <part name="parameters" element="tns:sayHello"/>
  </message>
  <message name="sayHelloResponse">
    <part name="parameters" element="tns:sayHelloResponse"/>
  </message>
  <message name="sayGoodbye">
    <part name="parameters" element="tns:sayGoodbye"/>
  </message>
  <message name="sayGoodbyeResponse">
    <part name="parameters" element="tns:sayGoodbyeResponse"/>
  </message>
  <portType name="Greeter">
    <operation name="sayHello">
      <input message="tns:sayHello"/>
      <output message="tns:sayHelloResponse"/>
    </operation>
    <operation name="sayGoodbye">
      <input message="tns:sayGoodbye"/>
      <output message="tns:sayGoodbyeResponse"/>
    </operation>
  </portType>
  <binding name="GreeterPortBinding" type="tns:Greeter">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <operation name="sayHello">
      <soap12:operation soapAction=""/>
      <input>
        <soap12:body use="literal"/>
      </input>
      <output>
        <soap12:body use="literal"/>
      </output>
    </operation>
    <operation name="sayGoodbye">
      <soap12:operation soapAction=""/>
      <input>
        <soap12:body use="literal"/>
      </input>
      <output>
        <soap12:body use="literal"/>
      </output>
    </operation>
  </binding>
  <service name="GreeterService">
    <port name="GreeterPort" binding="tns:GreeterPortBinding">
      <soap12:address location="http://onemoredemo.appspot.com/hellosoapserver1"/>
    </port>
  </service>
</definitions>

和GreeterService_schema1.xsd代码

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" targetNamespace="http://example.com/" xmlns:tns="http://example.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="sayGoodbye" type="tns:sayGoodbye"/>

  <xs:element name="sayGoodbyeResponse" type="tns:sayGoodbyeResponse"/>

  <xs:element name="sayHello" type="tns:sayHello"/>

  <xs:element name="sayHelloResponse" type="tns:sayHelloResponse"/>

  <xs:complexType name="sayHello">
    <xs:sequence>
      <xs:element name="arg0" type="xs:string" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="sayHelloResponse">
    <xs:sequence>
      <xs:element name="return" type="xs:string" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="sayGoodbye">
    <xs:sequence>
      <xs:element name="arg0" type="xs:string" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="sayGoodbyeResponse">
    <xs:sequence>
      <xs:element name="return" type="xs:string" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>

据我了解SOAP1.2 Web服务WSGEN工具的一些文章是正确生成WSDL文件,但是当我部署它,它是给在SOAP1.1的形式回应任何一个可以请请帮助为什么我没有得到的输出格式如下所示SOAP1.2协议

 <?xml version="1.0"?>
    <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
    xmlns:e="http://[app-id].appspot.com/gevents-service">
    <env:Body>
    </env:Body>
web-services google-app-engine soap wsdl
1个回答
0
投票

我看到你的命令开始:

wsgen -extension -wsdl:Xsoap1.2,但后来有-wsdl -keep -r等等......难道-wsdl第二个出场的是覆盖第一个使用的1.1的默认值?

© www.soinside.com 2019 - 2024. All rights reserved.