昨天导师从美国回来,经过陈工导师和王工的悉心指导,终于完成了配置,可以在浏览器中访问。
首先在service.config里添加svc配置
<service name="SugarCRM2.svc">
<path>\services\IDataServiceQueryProvider2 Implementation\SugarCRM\SugarCRMDataService.php</path>
<classname>SugarCRMDataService</classname>
<baseURL>/SugarCRM2.svc</baseURL>
</service>
然后在根目录下添加.htaccess文件,内容为
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule (\.svc.*) OData/Index.php
</IfModule>
即为重写的规则,并开启apache的重写功能
之后在php中添加odata producer的库
即在php.ini中添加
include_path = ".;D:\wamp\www\Odata\library;";
重启服务器,在浏览器中输入
http://127.0.0.1/WordPress.svc/Posts(1) 返回了XML格式的数据
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<entry xml:base="http://127.0.0.1:80/WordPress.svc" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom" m:etag="W/"datetime'2014-03-09T16:17:03'"">
<id>http://127.0.0.1:80/WordPress.svc/Posts(PostID=1)</id>
<title type="text">Post</title>
<updated>2014-08-04T12:05:14+00:00</updated>
<author>
<name/>
</author>
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/User" type="application/atom+xml;type=entry" title="User" href="Posts(PostID=1)/User"/>
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Tags" type="application/atom+xml;type=feed" title="Tags" href="Posts(PostID=1)/Tags"/>
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Categories" type="application/atom+xml;type=feed" title="Categories" href="Posts(PostID=1)/Categories"/>
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Comments" type="application/atom+xml;type=feed" title="Comments" href="Posts(PostID=1)/Comments"/>
<category term="WordPress.Post" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<content type="application/xml">
<m:properties>
<d:PostID m:type="Edm.Int32">1</d:PostID>
<d:Author m:type="Edm.Int32">1</d:Author>
<d:Date m:type="Edm.DateTime">2013-12-02T09:06:51</d:Date>
<d:DateGmt m:type="Edm.DateTime">2013-12-02T01:06:51</d:DateGmt>
<d:Content m:type="Edm.String">?????????????????????</d:Content>
<d:Title m:type="Edm.String">????</d:Title>
<d:Excerpt m:type="Edm.String" m:null="true"/>
<d:Status m:type="Edm.String">publish</d:Status>
<d:CommentStatus m:type="Edm.String">open</d:CommentStatus>
<d:PingStatus m:type="Edm.String">open</d:PingStatus>
<d:Password m:type="Edm.String" m:null="true"/>
<d:Name m:type="Edm.String">hello-world</d:Name>
<d:ToPing m:type="Edm.String" m:null="true"/>
<d:Pinged m:type="Edm.String" m:null="true"/>
<d:Modified m:type="Edm.DateTime">2014-03-09T16:17:03</d:Modified>
<d:ModifiedGmt m:type="Edm.DateTime">2014-03-09T08:17:03</d:ModifiedGmt>
<d:ContentFiltered m:type="Edm.String" m:null="true"/>
<d:ParentID m:type="Edm.Int32">0</d:ParentID>
<d:Guid m:type="Edm.String">http://127.0.0.1/wp/?p=1</d:Guid>
<d:MenuOrder m:type="Edm.Int32">0</d:MenuOrder>
<d:Type m:type="Edm.String">post</d:Type>
<d:MimeType m:type="Edm.String" m:null="true"/>
<d:CommentCount m:type="Edm.Int32">1</d:CommentCount>
</m:properties>
</content>
</entry>
至此测试成功