I have a problem in returning complex type from method over WCF webservice hosted in python spyne framework. Currently at C# side im having this sample of code:
var myBinding = new BasicHttpBinding();
var myEndpoint = new EndpointAddress("http://127.0.0.1:7706/FileOperationsBase");
var myChannelFactory = new ChannelFactory<FileOperationsBase>(myBinding, myEndpoint);
FileOperationsBase fileOp = myChannelFactory.CreateChannel();
var result = fileOp.FileExists("qweqweqweawdasdasdasdsa");
var result2 = fileOp.CreateFile("qweqweqweawdasdasdasdsa");
[ServiceContract]
public interface FileOperationsBase
{
[OperationContract]
bool FileExists(string filename);
[OperationContract]
MTFileInfo CreateFile(string filename);
}
[DataContract]
public class MTFileInfo
{
[DataMember]
public string Path { get; set; }
}
First result with simple type (bool) is working as expected, but in the second case i'm recieving MTFileInfo with properties set to null. Wireshark is showing that response is recieved, so it is not a problem with webservice itself.
What am I doing wrong?
application = Application([FileOperationsBase],
tns='http://tempuri.org/',
in_protocol=Soap11(),
out_protocol=Soap11()
)
if __name__ == '__main__':
# You can use any Wsgi server. Here, we chose
# Python's built-in wsgi server but you're not
# supposed to use it in production.
from wsgiref.simple_server import make_server
wsgi_app = WsgiMounter({
'': application,
})
srv = make_server('0.0.0.0', 7706, wsgi_app)
srv.serve_forever()
class MTFileInfo(ComplexModel):
_type_info = [
('Attribute', String.customize(sub_name='Attributes')),
('CreationDate', DateTime),
('IsDirectory', Boolean),
('LastMoficationDate', DateTime),
('Path', String),
('Sha1', String),
('Size', Long)
]
class FileOperationsBase(ServiceBase):
@srpc(Unicode, _returns=MTFileInfo)
def CreateFile(path):
print("CreateFileBEGIN")
print(path)
fileInfo = MTFileInfo()
fileInfo.Attribute = "Normal"
fileInfo.CreationDate = datetime.now()
fileInfo.IsDirectory = True
fileInfo.Path = "path"
fileInfo.LastMoficationDate = datetime.now()
fileInfo.Size = 9999
fileInfo.Sha1 = "asdagfsdfgdfhdghgfjgfjgsfg"
print("CreateFileAllEND")
return fileInfo
Aucun commentaire:
Enregistrer un commentaire