SOAP 客户端响应
SOAP client response
我正在尝试使用大型机系统中的 Web 服务。我从 WSDL 生成了存根,它生成的端点代码如下所示
@WebMethod(operationName = "ADDWEBSOperation")
@RequestWrapper(localName = "ADDWEBSOperation", targetNamespace = "http://www.*****.******.Request.com", className = "com.*****.*****.addwebs.ProgramInterface")
@ResponseWrapper(localName = "ADDWEBSOperationResponse", targetNamespace = "http://www.***.***.Response.com", className = "com.*****.*****.addwebs.ProgramInterface")
public void addwebsOperation(
@WebParam(name = "Num1", targetNamespace = "http://www.***.****.Request.com", mode = WebParam.Mode.INOUT)
Holder<Integer> num1,
@WebParam(name = "Num2", targetNamespace = "http://www.*****.*****.Request.com", mode = WebParam.Mode.INOUT)
Holder<Integer> num2,
@WebParam(name = "Result", targetNamespace = "http://www.*****.*****.Request.com", mode = WebParam.Mode.INOUT)
Holder<Integer> result);
}
它表明此服务端点未返回任何内容(无效)。
它是一个简单的计算器服务,其中添加了 Num1
和 Num2
并将其移动到 Result
。
现在,如果我在 SOAP 中使用 WSDL UI,它会给我一个正确的响应。
我已经完成了类似的编码。
public class TestClass {
public static void main(String[] args) {
ADDWEBSService srvc = new ADDWEBSService();
Holder<Integer> n2 = new Holder<Integer>();
Holder<Integer> n1 = new Holder<Integer>();
Holder<Integer> rs = new Holder<Integer>();
n1.value = 10;
n2.value = 2;
srvc.getADDWEBSPort().addwebsOperation(n1, n2, rs);
}
}
我不知道如何获得显示结果。我的服务调用是成功的,但我需要帮助来显示这里的响应值 (rs)..
这是 WSDL 的 spinet。
<?xml version="1.0" ?>
<definitions targetNamespace="http://www.***.***.com" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:reqns="http://www.***.***.Request.com" xmlns:resns="http://www.***.***.Response.com" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.***.***.com">
<types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.***.***.Request.com" xmlns:tns="http://www.***.***.Request.com">
<xsd:annotation>
<xsd:documentation source="http://www.***.com/sftware/***/cics/annotations">This schema was generated by the CICS Web services assistant.</xsd:documentation>
</xsd:annotation>
<xsd:annotation>
<xsd:appinfo source="http://www.***.com/sftware/***/cics/annotations">
com.***.cics.wsdl.properties.mappingLevel=3.0</xsd:appinfo>
</xsd:annotation>
<xsd:complexType abstract="false" block="#all" final="#all" mixed="false" name="ProgramInterface">
<xsd:sequence>
<xsd:element name="Num1" nillable="false">
<xsd:simpleType>
<xsd:annotation>
<xsd:appinfo source="http://www.***.com/sftware/***/cics/annotations">
com.***.cics.wsdl.properties.synchronized=false</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:unsignedShort">
<xsd:maxInclusive value="99"/>
<xsd:minInclusive value="0"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="Num2" nillable="false">
<xsd:simpleType>
<xsd:annotation>
<xsd:appinfo source="http://www.***.com/sftware/***/cics/annotations">
com.***.cics.wsdl.properties.synchronized=false</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:unsignedShort">
<xsd:maxInclusive value="99"/>
<xsd:minInclusive value="0"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="Result" nillable="false">
<xsd:simpleType>
<xsd:annotation>
<xsd:appinfo source="http://www.***.com/sftware/***/cics/annotations">
com.***.cics.wsdl.properties.synchronized=false</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:unsignedShort">
<xsd:maxInclusive value="9999"/>
<xsd:minInclusive value="0"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ADDWEBSOperation" nillable="false" type="tns:ProgramInterface"/>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.***.***.Response.com" xmlns:tns="http://www.***.***.Response.com">
<xsd:annotation>
<xsd:documentation source="http://www.***.com/sftware/***/cics/annotations">This schema was generated by the CICS Web services assistant.</xsd:documentation>
</xsd:annotation>
<xsd:annotation>
<xsd:appinfo source="http://www.***.com/sftware/***/cics/annotations">
com.***.cics.wsdl.properties.mappingLevel=3.0</xsd:appinfo>
</xsd:annotation>
<xsd:complexType abstract="false" block="#all" final="#all" mixed="false" name="ProgramInterface">
<xsd:sequence>
<xsd:element name="Num1" nillable="false">
<xsd:simpleType>
<xsd:annotation>
<xsd:appinfo source="http://www.***.com/sftware/***/cics/annotations">
com.***.cics.wsdl.properties.synchronized=false</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:unsignedShort">
<xsd:maxInclusive value="99"/>
<xsd:minInclusive value="0"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="Num2" nillable="false">
<xsd:simpleType>
<xsd:annotation>
<xsd:appinfo source="http://www.***.com/sftware/***/cics/annotations">
com.***.cics.wsdl.properties.synchronized=false</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:unsignedShort">
<xsd:maxInclusive value="99"/>
<xsd:minInclusive value="0"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="Result" nillable="false">
<xsd:simpleType>
<xsd:annotation>
<xsd:appinfo source="http://www.***.com/sftware/***/cics/annotations">
com.***.cics.wsdl.properties.synchronized=false</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:unsignedShort">
<xsd:maxInclusive value="9999"/>
<xsd:minInclusive value="0"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ADDWEBSOperationResponse" nillable="false" type="tns:ProgramInterface"/>
</xsd:schema>
</types>
<message name="ADDWEBSOperationResponse">
<part element="resns:ADDWEBSOperationResponse" name="ResponsePart"/>
</message>
<message name="ADDWEBSOperationRequest">
<part element="reqns:ADDWEBSOperation" name="RequestPart"/>
</message>
<portType name="ADDWEBSPort">
<operation name="ADDWEBSOperation">
<input message="tns:ADDWEBSOperationRequest" name="ADDWEBSOperationRequest"/>
<output message="tns:ADDWEBSOperationResponse" name="ADDWEBSOperationResponse"/>
</operation>
</portType>
<binding name="ADDWEBSHTTPSoapBinding" type="tns:ADDWEBSPort">
<!-- This soap:binding indicates the use of SOAP 1.1 -->
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="ADDWEBSOperation">
<soap:operation soapAction="" style="document"/>
<input name="ADDWEBSOperationRequest">
<soap:body parts="RequestPart" use="literal"/>
</input>
<output name="ADDWEBSOperationResponse">
<soap:body parts="ResponsePart" use="literal"/>
</output>
</operation>
</binding>
<service name="ADDWEBSService">
<port binding="tns:ADDWEBSHTTPSoapBinding" name="ADDWEBSPort">
<!-- This soap:address indicates the location of the Web service over HTTP.
Please replace "my-server" with the TCPIP host name of your CICS region.
Please replace "my-port" with the port number of your CICS TCPIPSERVICE. -->
<soap:address location="http://**.**.*.***:****/addwebs"/>
<!-- This soap:address indicates the location of the Web service over HTTPS. -->
<!-- <soap:address location="https://my-server:my-port/addwebs"/> -->
<!-- This soap:address indicates the location of the Web service over WebSphere MQSeries.
Please replace "my-queue" with the appropriate queue name. -->
<!-- <soap:address location="jms:/queue?destination=my-queue&connectionFactory=()&targetService=/addwebs&initialContextFactory=com.***.mq.jms.Nojndi" /> -->
</port>
</service>
</definitions>
我已经通过创建 SOAP 请求 XML 并通过 HTTPConnection 发送它并收到 XML 响应解决了这个问题。使用从 WSDL 生成的存根不可能获得结果。所以我选择了这个方法
我正在尝试使用大型机系统中的 Web 服务。我从 WSDL 生成了存根,它生成的端点代码如下所示
@WebMethod(operationName = "ADDWEBSOperation")
@RequestWrapper(localName = "ADDWEBSOperation", targetNamespace = "http://www.*****.******.Request.com", className = "com.*****.*****.addwebs.ProgramInterface")
@ResponseWrapper(localName = "ADDWEBSOperationResponse", targetNamespace = "http://www.***.***.Response.com", className = "com.*****.*****.addwebs.ProgramInterface")
public void addwebsOperation(
@WebParam(name = "Num1", targetNamespace = "http://www.***.****.Request.com", mode = WebParam.Mode.INOUT)
Holder<Integer> num1,
@WebParam(name = "Num2", targetNamespace = "http://www.*****.*****.Request.com", mode = WebParam.Mode.INOUT)
Holder<Integer> num2,
@WebParam(name = "Result", targetNamespace = "http://www.*****.*****.Request.com", mode = WebParam.Mode.INOUT)
Holder<Integer> result);
}
它表明此服务端点未返回任何内容(无效)。
它是一个简单的计算器服务,其中添加了 Num1
和 Num2
并将其移动到 Result
。
现在,如果我在 SOAP 中使用 WSDL UI,它会给我一个正确的响应。
我已经完成了类似的编码。
public class TestClass {
public static void main(String[] args) {
ADDWEBSService srvc = new ADDWEBSService();
Holder<Integer> n2 = new Holder<Integer>();
Holder<Integer> n1 = new Holder<Integer>();
Holder<Integer> rs = new Holder<Integer>();
n1.value = 10;
n2.value = 2;
srvc.getADDWEBSPort().addwebsOperation(n1, n2, rs);
}
}
我不知道如何获得显示结果。我的服务调用是成功的,但我需要帮助来显示这里的响应值 (rs)..
这是 WSDL 的 spinet。
<?xml version="1.0" ?>
<definitions targetNamespace="http://www.***.***.com" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:reqns="http://www.***.***.Request.com" xmlns:resns="http://www.***.***.Response.com" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.***.***.com">
<types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.***.***.Request.com" xmlns:tns="http://www.***.***.Request.com">
<xsd:annotation>
<xsd:documentation source="http://www.***.com/sftware/***/cics/annotations">This schema was generated by the CICS Web services assistant.</xsd:documentation>
</xsd:annotation>
<xsd:annotation>
<xsd:appinfo source="http://www.***.com/sftware/***/cics/annotations">
com.***.cics.wsdl.properties.mappingLevel=3.0</xsd:appinfo>
</xsd:annotation>
<xsd:complexType abstract="false" block="#all" final="#all" mixed="false" name="ProgramInterface">
<xsd:sequence>
<xsd:element name="Num1" nillable="false">
<xsd:simpleType>
<xsd:annotation>
<xsd:appinfo source="http://www.***.com/sftware/***/cics/annotations">
com.***.cics.wsdl.properties.synchronized=false</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:unsignedShort">
<xsd:maxInclusive value="99"/>
<xsd:minInclusive value="0"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="Num2" nillable="false">
<xsd:simpleType>
<xsd:annotation>
<xsd:appinfo source="http://www.***.com/sftware/***/cics/annotations">
com.***.cics.wsdl.properties.synchronized=false</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:unsignedShort">
<xsd:maxInclusive value="99"/>
<xsd:minInclusive value="0"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="Result" nillable="false">
<xsd:simpleType>
<xsd:annotation>
<xsd:appinfo source="http://www.***.com/sftware/***/cics/annotations">
com.***.cics.wsdl.properties.synchronized=false</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:unsignedShort">
<xsd:maxInclusive value="9999"/>
<xsd:minInclusive value="0"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ADDWEBSOperation" nillable="false" type="tns:ProgramInterface"/>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.***.***.Response.com" xmlns:tns="http://www.***.***.Response.com">
<xsd:annotation>
<xsd:documentation source="http://www.***.com/sftware/***/cics/annotations">This schema was generated by the CICS Web services assistant.</xsd:documentation>
</xsd:annotation>
<xsd:annotation>
<xsd:appinfo source="http://www.***.com/sftware/***/cics/annotations">
com.***.cics.wsdl.properties.mappingLevel=3.0</xsd:appinfo>
</xsd:annotation>
<xsd:complexType abstract="false" block="#all" final="#all" mixed="false" name="ProgramInterface">
<xsd:sequence>
<xsd:element name="Num1" nillable="false">
<xsd:simpleType>
<xsd:annotation>
<xsd:appinfo source="http://www.***.com/sftware/***/cics/annotations">
com.***.cics.wsdl.properties.synchronized=false</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:unsignedShort">
<xsd:maxInclusive value="99"/>
<xsd:minInclusive value="0"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="Num2" nillable="false">
<xsd:simpleType>
<xsd:annotation>
<xsd:appinfo source="http://www.***.com/sftware/***/cics/annotations">
com.***.cics.wsdl.properties.synchronized=false</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:unsignedShort">
<xsd:maxInclusive value="99"/>
<xsd:minInclusive value="0"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="Result" nillable="false">
<xsd:simpleType>
<xsd:annotation>
<xsd:appinfo source="http://www.***.com/sftware/***/cics/annotations">
com.***.cics.wsdl.properties.synchronized=false</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:unsignedShort">
<xsd:maxInclusive value="9999"/>
<xsd:minInclusive value="0"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ADDWEBSOperationResponse" nillable="false" type="tns:ProgramInterface"/>
</xsd:schema>
</types>
<message name="ADDWEBSOperationResponse">
<part element="resns:ADDWEBSOperationResponse" name="ResponsePart"/>
</message>
<message name="ADDWEBSOperationRequest">
<part element="reqns:ADDWEBSOperation" name="RequestPart"/>
</message>
<portType name="ADDWEBSPort">
<operation name="ADDWEBSOperation">
<input message="tns:ADDWEBSOperationRequest" name="ADDWEBSOperationRequest"/>
<output message="tns:ADDWEBSOperationResponse" name="ADDWEBSOperationResponse"/>
</operation>
</portType>
<binding name="ADDWEBSHTTPSoapBinding" type="tns:ADDWEBSPort">
<!-- This soap:binding indicates the use of SOAP 1.1 -->
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="ADDWEBSOperation">
<soap:operation soapAction="" style="document"/>
<input name="ADDWEBSOperationRequest">
<soap:body parts="RequestPart" use="literal"/>
</input>
<output name="ADDWEBSOperationResponse">
<soap:body parts="ResponsePart" use="literal"/>
</output>
</operation>
</binding>
<service name="ADDWEBSService">
<port binding="tns:ADDWEBSHTTPSoapBinding" name="ADDWEBSPort">
<!-- This soap:address indicates the location of the Web service over HTTP.
Please replace "my-server" with the TCPIP host name of your CICS region.
Please replace "my-port" with the port number of your CICS TCPIPSERVICE. -->
<soap:address location="http://**.**.*.***:****/addwebs"/>
<!-- This soap:address indicates the location of the Web service over HTTPS. -->
<!-- <soap:address location="https://my-server:my-port/addwebs"/> -->
<!-- This soap:address indicates the location of the Web service over WebSphere MQSeries.
Please replace "my-queue" with the appropriate queue name. -->
<!-- <soap:address location="jms:/queue?destination=my-queue&connectionFactory=()&targetService=/addwebs&initialContextFactory=com.***.mq.jms.Nojndi" /> -->
</port>
</service>
</definitions>
我已经通过创建 SOAP 请求 XML 并通过 HTTPConnection 发送它并收到 XML 响应解决了这个问题。使用从 WSDL 生成的存根不可能获得结果。所以我选择了这个方法