[英]How to Consume Webservice SOAP Request and response contains header and body in java
I have the WSDL file from the bank whose service we have to consume. 我有银行的WSDL文件,我们必须使用其服务。 Using Apache axis 1.4 - WSDL2JAVA, I have generated all the proxy files.
使用Apache轴1.4-WSDL2JAVA,我生成了所有代理文件。
There are 4 methods I have to call. 我必须调用4种方法。 Each method's SOAP 1.1 request and response contains a Header and body in them.
每个方法的SOAP 1.1请求和响应都包含一个Header和主体。 In the request, the header is used to set the data to login and the body contains a object params to actually passe the parameters for my method
getCat
. 在请求中,标头用于设置要登录的数据,主体包含用于实际
getCat
我的方法getCat
的参数的对象参数。 In the response, I have the header_out
which passes me the connection Status, ErrorCode (for authentication) and body contains something like 在响应中,我有
header_out
,它向我传递了连接状态,ErrorCode(用于身份验证),并且主体包含类似
<GetCatResponse xmlns="WebServices">
<GetCatResult>
<xsd:schema>schema</xsd:schema>xml</GetCatResult>
</GetCatResponse>
Can any one tell me how I can write the client code to send the request and get the response. 谁能告诉我如何编写客户端代码以发送请求并获得响应。
Soap looks like below. 肥皂如下所示。
SOAPAction: "WebServices/GetCat"
<soap:Envelope ....>
<soap:Header>
<ws_Header xmlns="WebServices">
<sWebUser>string</sWebUser>
<sWebPassword>string</sWebPassword>
<sCompanyID>string</sCompanyID>
</ws_Header>
</soap:Header>
<soap:Body>
<GetCat xmlns="WebServices">
<ObjParms>
<sCountry>string</sCountry>
<sCatType>string</sCatType>
</ObjParms>
</GetCat>
</soap:Body>
</soap:Envelope>
RESPONSE 响应
<soap:Envelope ...>
<soap:Header>
<ws_Header_Out xmlns="WebServices">
<sFlagStatus>int</sFlagStatus>
<sErrorCode>string</sErrorCode>
</ws_Header_Out>
</soap:Header>
<soap:Body>
<GetCatResponse xmlns="WebServices">
<GetCatResult>
<xsd:schema>schema</xsd:schema>xml</GetCatResult>
</GetCatResponse>
</soap:Body>
</soap:Envelope>
You can use eclipse to generate webservice client code. 您可以使用eclipse生成Web服务客户端代码。 You give it a WSDL (or the location of it) and it will generate all the proxies for you.
您为其提供WSDL(或它的位置),它将为您生成所有代理。 See this tutorial
请参阅本教程
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.