如何使用SOAP网络服务的返回值在SOAP客户端
问题描述:
public WsResult doMyJob(String s, Information info);
的方法,当我生成客户端了WSDL的SOAP Web服务,在客户端代码我的web服务的方法成为类似:
public Object doMyJob(String s, Object arg0);
的问题是,我希望客户能够实现/看我的自定义类(WsResult和信息),而在他的代码显式定义它们。
这是甚至可能的,如果是的话如何?
感谢
编辑:
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions name="SendSms" targetNamespace="http://webservice.aaa.bbb.com/" xmlns:ns1="http://webservice.aaa.bbb.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://webservice.aaa.bbb.com/" xmlns="http://webservice.aaa.bbb.com/" xmlns:tns="http://impl.webservice.aaa.bbb.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="registerScheduledSms" type="registerScheduledSms" />
<xsd:complexType name="registerScheduledSms">
<xsd:sequence>
<xsd:element minOccurs="0" name="arg0" type="xsd:string" />
<xsd:element minOccurs="0" name="arg1" /> **HERE THERE SHOULD BE xsd definition for my custom class**
<xsd:element minOccurs="0" name="arg2" /> **and here**
<xsd:element minOccurs="0" name="arg3" type="xsd:dateTime" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="registerScheduledSmsResponse" type="registerScheduledSmsResponse" />
<xsd:complexType name="registerScheduledSmsResponse">
<xsd:sequence>
<xsd:element minOccurs="0" name="return" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="registerScheduledSmsResponse">
<wsdl:part element="ns1:registerScheduledSmsResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="registerScheduledSms">
<wsdl:part element="ns1:registerScheduledSms" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="SendSms">
<wsdl:operation name="registerScheduledSms">
<wsdl:input message="ns1:registerScheduledSms" name="registerScheduledSms">
</wsdl:input>
<wsdl:output message="ns1:registerScheduledSmsResponse" name="registerScheduledSmsResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>
我的服务代码
@WebService(endpointInterface = "com.bbb.aaa.webservice.SendSms")
public class SendSmsImpl implements SendSms {
private DbService dbService;
@Override
public WsResult registerScheduledSms(String applicationId,
ServiceAccount serviceAccount, Sms sms, Date scheduledDate) {
return dbService.addNewScheduledSms(applicationId, serviceAccount, sms, scheduledDate);
}
}
答
是的,这是完全可能的。您的肥皂客户端应生成您的WSDL上的架构类型中定义的所有类。你很可能在客户代中错过了一些东西。
如果您使用的是客户端代(AXIS,.NET,JAX-WS)指定什么并确认您的WSDL包含模式定义为WsResult
和Information
类型这将有助于。
嗨,感谢您的回答,我正在使用JAX-WS(wsdl2java二进制)生成wsdl客户端。但在我的wsdl文件中没有关于我的自定义类的信息。我知道这是问题所在。我怎么能让我的服务器用我的自定义类的定义生成wsdl? – dds 2010-12-04 11:48:37