0
我必須爲pdf轉換爲tif創建一個WCF服務。服務應該 -wcf服務使用Ghostscript的pdf轉換爲tiff
1)接受爲輸入兩個字符串 - 輸入文件路徑和輸出文件路徑 2)應該將輸入(PDF)文件並將其保存爲TIF文件給定輸出路徑上
請幫助我,因爲我是新的wcf concepts.Thanks提前。
我必須爲pdf轉換爲tif創建一個WCF服務。服務應該 -wcf服務使用Ghostscript的pdf轉換爲tiff
1)接受爲輸入兩個字符串 - 輸入文件路徑和輸出文件路徑 2)應該將輸入(PDF)文件並將其保存爲TIF文件給定輸出路徑上
請幫助我,因爲我是新的wcf concepts.Thanks提前。
讓鐵餅可能的解決方案。使用HTTP綁定的簡單WCF服務。
您將需要一些API來執行PDF轉換。
首先創建類庫,並把這樣的事情在裏面:
// WCF Service interface
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
[ServiceContract]
public interface IPdfConvertor
{
[OperationContract]
void PdfToTif(string sourceFilePath, string destinationFilePath);
}
比你要實現接口
// WCF服務實現
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall,
IncludeExceptionDetailInFaults=true)]
public class PdfConvertor:IPdfConvertor
{
public void PdfToTif(string sourceFilePath, string destinationFilePath)
{
// Perform conversion here
}
}
這是有關服務。當你製作它時,你必須選擇如何託管它。 您有幾種選擇託管: 1)IIS 2)Windows服務 3)的Windows .NET應用程序
無論舉辦它。您必須配置端點。把你的配置放在Web.config或App.config中,像這樣:
<system.serviceModel>
<services>
<service name="SomeNameSpace.PdfConvertor" behaviorConfiguration="ServiceMetadataBehavior">
<endpoint contract="SomeNameSpace.IPdfConvertor" name="BasicHttpBinding_IPdfConvertor" binding="basicHttpBinding" address="http://localhost:8000/PdfConvertor"/>
<endpoint address="http://localhost:8000/mex" binding="mexHttpBinding"contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IPdfConvertor"/>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceMetadataBehavior">
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8000/mex" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
這只是一個框架。我希望能幫助您對您的問題採取一些可能的解決方案。
也可以嘗試讀一些基礎教程有關WCF:http://msdn.microsoft.com/en-us/library/ms734712.aspx
感謝slobodans.this證明有用!。 – sobsinha
歡迎您:) – slobodans