.NET Client 怎样处理异常
调试.NET客户,在vs中添加web引用,然后在url 中直接输入webservice地址。java web service 服务器定义是: String sayHi(String text, ProfileInfo info) throws BusinessLogicException;
.NET客户代码
localhost.HelloWorldService hw = new localhost.HelloWorldService();
localhost.profileInfo info = new localhost.profileInfo();
pro.firstName = "xxx";
try
{
Button1.Text = hw.sayHi("Hello ", info);
}
catch (Exception exception) //<---- 如何处理BusinessLogicException
{
Console.WriteLine(exception);
string msg = exception.Message;
}
我可以看到生成的localhost.HelloWorldService 和 localhost.profileInfo。但是找不到BusinessLogicException代码。
这样正确吗?以下是我在url 中直接输入的 wsdl的内容。
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:tns="http://spring.demo/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="HelloWorldService" targetNamespace="http://spring.demo/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://spring.demo/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="BusinessLogicFaultDetail" nillable="true" type="tns:BusinessLogicFaultDetail" />
<xs:element name="sayHi" nillable="true" type="tns:sayHi" />
<xs:element name="sayHiResponse" nillable="true" type="tns:sayHiResponse" />
<xs:complexType name="sayHi">
<xs:sequence>
<xs:element minOccurs="0" name="text" type="xs:string" />
<xs:element minOccurs="0" name="info" type="tns:profileInfo" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="profileInfo">
<xs:sequence>
<xs:element minOccurs="0" name="addressLine1" type="xs:string" />
<xs:element minOccurs="0" name="addressLine2" type="xs:string" />
<xs:element minOccurs="0" name="city" type="xs:string" />
<xs:element minOccurs="0" name="companyName" type="xs:string" />
<xs:element minOccurs="0" name="email" type="xs:string" />
<xs:element minOccurs="0" name="fax" type="xs:string" />
<xs:element minOccurs="0" name="firstName" type="xs:string" />
<xs:element minOccurs="0" name="lastName" type="xs:string" />
<xs:element minOccurs="0" name="middleName" type="xs:string" />
<xs:element minOccurs="0" name="mobile" type="xs:string" />
<xs:element minOccurs="0" name="phone" type="xs:string" />
<xs:element minOccurs="0" name="state" type="xs:string" />
<xs:element minOccurs="0" name="status" type="xs:string" />
<xs:element minOccurs="0" name="zip" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="sayHiResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="BusinessLogicFaultDetail" />
</xs:schema>
</wsdl:types>
<wsdl:message name="BusinessLogicException">
<wsdl:part name="BusinessLogicException" element="tns:BusinessLogicFaultDetail" />
</wsdl:message>
<wsdl:message name="sayHiResponse">
<wsdl:part name="parameters" element="tns:sayHiResponse" />
</wsdl:message>
<wsdl:message name="sayHi">
<wsdl:part name="parameters" element="tns:sayHi" />
</wsdl:message>
<wsdl:portType name="HelloWorld">
<wsdl:operation name="sayHi">
<wsdl:input name="sayHi" message="tns:sayHi" />
<wsdl:output name="sayHiResponse" message="tns:sayHiResponse" />
<wsdl:fault name="BusinessLogicException" message="tns:BusinessLogicException" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloWorldServiceSoapBinding" type="tns:HelloWorld">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="sayHi">
<soap:operation soapAction="" style="document" />
<wsdl:input name="sayHi">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="sayHiResponse">
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="BusinessLogicException">
<soap:fault use="literal" name="BusinessLogicException"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloWorldService">
<wsdl:port name="HelloWorldPort" binding="tns:HelloWorldServiceSoapBinding">
<soap:address location="http://localhost:9090/spring_http/ws/ServerEndPoint" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions> --------------------编程问答-------------------- http://www.blogjava.net/gf7/default.html?page=3或许有用 --------------------编程问答-------------------- 不明LZ在说什么 --------------------编程问答-------------------- 没遇到过这种情况.
补充:.NET技术 , Web Services