主题:java 调用.net 写的WebService 问题求解!!!

 为了实现新闻的同步而做,现在有一java平台,一个.net平台,在java平台里发布一条新闻后需要同步到.net平台上,于是找到了.net开发人员,给了我下面的这些代码,别的什么也没有,说是可以实现,我是开发java的,对C#不了解,请各位看一看这代码,能不能实现,如果可以的话,我应该如何来实现这一功能!!

using System;
using System.Net;
using MCMSProxy.MCMSServer;
namespace MCMSProxy
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class Client
{

MCMSServer.MCMS  MCMSServer=new MCMS();
bool _readOnly=false;
public Client(string Url)
{
//
// TODO: Add constructor logic here
//
SiteUrl=Url;
MCMSServer.CookieContainer = new System.Net.CookieContainer();
}

public Client(string Url,bool readOnly)
{
//
// TODO: Add constructor logic here
//
_readOnly=readOnly;
SiteUrl=Url;
MCMSServer.CookieContainer = new System.Net.CookieContainer();
}
/// <summary>
/// 添加新的新闻
/// </summary>
/// <param name="ChannelPath">频道相对于根的路径。例如:http://server/CmsRoot 写为“CmsRoot”</param>
/// <param name="Name">新闻名称</param>
/// <param name="DisplayName">显示名称</param>
/// <param name="Template">模板相对于根的路径</param>
/// <param name="thePlaceholders">内容集合</param>
/// <param name="theCustomProperties">个性化属性集合</param>
/// <returns>新生成的新闻的GUID</returns>
public string AddNews(string ChannelPath,string Name,string DisplayName,string TemplatePath,System.Collections.DictionaryEntry[] thePlaceholders,System.Collections.DictionaryEntry[]  theCustomProperties)
{
CheckCredentials();
MCMSProxy.MCMSServer.DictionaryEntry[] thePlaceholders2=null;
if(thePlaceholders!=null)
{
thePlaceholders2= new  MCMSProxy.MCMSServer.DictionaryEntry[thePlaceholders.Length];
for(int i=0;i<thePlaceholders.Length;i++)
{
thePlaceholders2[i]=new  MCMSProxy.MCMSServer.DictionaryEntry();
thePlaceholders2[i].Key = thePlaceholders[i].Key;
thePlaceholders2[i].Value = thePlaceholders[i].Value;
}
}

MCMSProxy.MCMSServer.DictionaryEntry[] theCustomProperties2=null;
if(theCustomProperties!=null)
{
theCustomProperties2= new  MCMSProxy.MCMSServer.DictionaryEntry[theCustomProperties.Length];
for(int i=0;i<theCustomProperties2.Length;i++)
{
theCustomProperties2[i]=new  MCMSProxy.MCMSServer.DictionaryEntry();
theCustomProperties2[i].Key = theCustomProperties[i].Key;
theCustomProperties2[i].Value = theCustomProperties[i].Value;
}
}
return MCMSServer.AddNews(ChannelPath,Name,DisplayName,TemplatePath,thePlaceholders2,theCustomProperties2);
}
/// <summary>
/// 添加新的新闻,适用于只有一个placeholder且 placeholder名为"content"的新闻模板,例如:常用工具/新闻(自动生成标题)
/// </summary>
/// <param name="ChannelPath">频道相对于根的路径。例如:http://server/CmsRoot 写为“CmsRoot”</param>
/// <param name="Name">新闻名称</param>
/// <param name="DisplayName">显示名称</param>
/// <param name="Template">模板相对于根的路径</param>
/// <param name="Content">内容</param>
/// <param name="theCustomProperties">个性化属性集合</param>
/// <returns>新生成的新闻的GUID</returns>
public string AddNews(string ChannelPath,string Name,string DisplayName,string TemplatePath,string Content,System.Collections.DictionaryEntry[]  theCustomProperties)
{
System.Collections.DictionaryEntry[] thePlaceholders= new  System.Collections.DictionaryEntry[1];
thePlaceholders[0]=new System.Collections.DictionaryEntry();
thePlaceholders[0].Key="Content";
thePlaceholders[0].Value =Content;
return AddNews(ChannelPath,Name,DisplayName,TemplatePath,thePlaceholders,theCustomProperties);
}
/// <summary>
/// 发布新闻
/// </summary>
/// <param name="PostingGuid">被发布新闻的GUID</param>
/// <param name="startDate">开始发布时间</param>
/// <param name="ExpiryDate">过期时间</param>
/// <returns>是否成功发布</returns>
public bool PublishNews(string PostingGuid, DateTime startDate, DateTime ExpiryDate)
{
CheckCredentials();

return MCMSServer.PublishNews(PostingGuid,startDate,ExpiryDate);
}
/// <summary>
///
/// </summary>
/// <param name="_ChannelPath"></param>
/// <param name="_SummaryChannel"></param>
/// <param name="_Conditions"></param>
/// <param name="_Filter"></param>
/// <param name="_OrderBy"></param>
/// <param name="_DeepLevel"></param>
/// <param name="_SummarySubChannel"></param>
/// <param name="_maxCount"></param>
/// <param name="_postingcount"></param>
/// <returns></returns>
public System.Data.DataSet   ListNews(string SummaryChannel,string Conditions,string Filter,string OrderBy,int DeepLevel,bool SummarySubChannel,int maxCount,int postingcount)
{
CheckCredentials();

return MCMSServer.ListNews(SummaryChannel, Conditions, Filter, OrderBy, DeepLevel, SummarySubChannel, maxCount, postingcount);
}
/// <summary>
/// </summary>
/// <param name="ChannelPath"></param>
/// <param name="SummaryChannel"></param>
/// <param name="Conditions"></param>
/// <param name="postingcount"></param>
/// <returns></returns>
public System.Data.DataSet   ListNews( string SummaryChannel,string Conditions,int MaxCount)
{
//CheckCredentials();
return MCMSServer.ListNews( SummaryChannel, Conditions, "", "",-1, false,MaxCount, -1);
}

public System.Xml.XmlNode  getNews(string GUID)
{
CheckCredentials();
return MCMSServer.getNews(GUID);


}
public string FileToResource(byte[] iBuffer, string fileName)
{
CheckCredentials();
return MCMSServer.FileToResource(iBuffer,fileName);


}

private void CheckCredentials()
{
if(MCMSServer.Credentials==null)
MCMSServer.Credentials=System.Net.CredentialCache.DefaultCredentials; 
}
// public string GetLog()
// {
// try
// {
// return   MCMSServer.Getlog();
// }
// catch(Exception ex)
// {
// return "读取日志出错!"+ex.Message ;
// }
// }
// <summary>
// Wss site server Url or WebServer Url like "http://testserver/CmsWebService/MCMS.asmx?NRMODE=Update"
// </summary>
public string SiteUrl
{
set
{
string m_Site=value;
if(m_Site.EndsWith("/"))  m_Site=m_Site.Substring(0,m_Site.Length-1);
if(_readOnly)
{
if(m_Site.ToLower().EndsWith("mcms.asmx"))
MCMSServer.Url =m_Site;
else
MCMSServer.Url =m_Site+"/EipCmsTemplate/WebService/MCMS.asmx";
}
else
{
if(m_Site.ToLower().EndsWith("mcms.asmx?nrmode=update"))
MCMSServer.Url =m_Site;
else
MCMSServer.Url =m_Site+"/EipCmsTemplate/WebService/MCMS.asmx?NRMODE=Update";
}
}
}
/// <summary>
/// if use Proxy
/// </summary>
public System.Net.IWebProxy  Proxy
{
set
{
MCMSServer.Proxy =value;

}

}

/// <summary>
///  Credentials
/// </summary>
public ICredentials Credentials
{
set
{
MCMSServer.Credentials= value;
}

}


}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值