webservice 連接ORACLE出現問題

sweig0721 2006-03-07 10:42:25
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Data.OracleClient;


[ WebMethod(Description="get the oracle connection",EnableSession=true)]
public System.Data.OracleClient.OracleConnection getconn(string conn_string)
{
System.Data.OracleClient.OracleConnection myconn=new System.Data.OracleClient.OracleConnection(conn_string);
return myconn;
}

編譯沒有語法錯誤,但是提示
Server Error in '/mywebservice' Application.

Cannot serialize member System.ComponentModel.Component.Site of type System.ComponentModel.ISite because it is an interface.
請問怎么回事情?

但是下面的一個測試例子確沒有錯誤,可以使用并且在WINFORM中測試通過.
[ WebMethod(Description="返回相加結果",EnableSession=true)]
public int getadd(int a,int b)
{
return a+b;
}
急!!!!



...全文
112 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
sweig0721 2006-03-07
  • 打赏
  • 举报
回复
可以返回DATASET,但是不可以返回ORACLECONNECTION?
[ WebMethod(Description="get the oracle ds",EnableSession=true)]
public System.Data.DataSet getmyds(string sql_string)
{
System.Data.OracleClient.OracleConnection oraconn=new OracleConnection("user id=miscode;data source=cncl;password=wuscnmis");
System.Data.OracleClient.OracleDataAdapter myda=new OracleDataAdapter("select * from xh_fan_fan_main where yymm='200602'",oraconn);
System.Data.DataSet ds=new DataSet();
ds.Clear();
myda.Fill(ds,"search");
return ds;
}
測試通過.
WEBSERVICE返回類型有什么限制呢?怎么沒有人解答?我要急貼了.
sweig0721 2006-03-07
  • 打赏
  • 举报
回复
ding!!!!!!!!!!
开发者开聊 2006-03-07
  • 打赏
  • 举报
回复
ASP.NET中web service能使用的类型:

Table 32-3.Web Service Data Types for Parameters and Return Values
Data Type Description

The Basics Simple

C# data types such as integers (short, int, long), unsigned
integers (ushort, uint, ulong), nonintegral numeric types (float,
double, decimal), and a few other miscellaneous types (bool, string,
char, byte, and DateTime).

Arrays

You can use arrays of any supported type. You can also use an
ArrayList (which is simply converted into an array), but you can’t use
more specialized collections such as the Hashtable. You can also use
binary data through byte arrays. Binary data is automatically Base64
encoded so that it can be inserted into an XML web service message.

Custom Objects

You can pass any object you create based on a custom class or
structure. The only limitation is that only public data members are
transmitted, and all public members and properties must use one of
the other supported data types. If you use a class that includes custom
methods, these methods will not be transmitted to the client, and they
will not be accessible to the client.

Enumerations

Enumerations types (defined in C# with the enum keyword) are
supported. However, the web service uses the string name of the
enumeration value (not the underlying integer).

XmlNode

Objects based on System.Xml.XmlNode are representations of a
portion of an XML document. You can use this to send arbitrary XML.

DataSet and DataTable

You can use the DataSet and DataTable to return information from a
relational database. Other ADO.NET data objects, such as Data-
Columns and DataRows, aren’t supported. When you use a DataSet or
DataTable, it’s automatically converted to XML in a similar way as if
you had used the GetXml() or WriteXml() method.

■Note The supported web service data types are based on the types defined by the XML Schema standard.
These map fairly well to the basic set of C# data types.

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧