提交 315223df 编写于 作者: JasonWcx's avatar JasonWcx

增加ResponseContentType和WebServiceAttribute

上级 fdafabf3
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mozi.HttpEmbedded.Attributes
{
/// <summary>
/// 响应内容 文档类型
/// </summary>
[AttributeUsage(AttributeTargets.ReturnValue)]
internal class ResponseContentTypeAttribute : Attribute
{
public string ContentType { get; set; }
public string Encoding { get; set; }
public ResponseContentTypeAttribute(string contentType,string encoding)
{
ContentType = contentType;
Encoding = encoding;
}
public ResponseContentTypeAttribute(string contentType):this(contentType,"")
{
}
}
}
using System;
namespace Mozi.HttpEmbedded.Attributes
{
[AttributeUsage(AttributeTargets.Class)]
internal class WebServiceAttribute:Attribute
{
public string Namespace = "";
public string DocumentName = "";
}
}
......@@ -65,6 +65,8 @@
<Compile Include="ASCIICode.cs" />
<Compile Include="Attributes\BasicApiAttribute.cs" />
<Compile Include="Attributes\HttpMethodAttribute.cs" />
<Compile Include="Attributes\ResponseContentTypeAttribute.cs" />
<Compile Include="Attributes\WebServiceAttribute.cs" />
<Compile Include="Auth\User.cs" />
<Compile Include="Cache\MemoryCache.cs" />
<Compile Include="Cert\CertManager.cs" />
......
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Reflection;
using Mozi.HttpEmbedded.Attributes;
namespace Mozi.HttpEmbedded.Page
{
......
......@@ -5,11 +5,14 @@ using Mozi.HttpEmbedded.Generic;
namespace Mozi.HttpEmbedded.WebService
{
/// <summary>
/// SOAP envelope封装
/// </summary>
public class SOAPEnvelope
{
public string xsi = "http://www.w3.org/2001/XMLSchema-instance";
public string xsd= "http://www.w3.org/2001/XMLSchema";
public string encodingStyle = "http://www.w3.org/2001/12/soap-encoding";
public string NS_XSI = "http://www.w3.org/2001/XMLSchema-instance";
public string NS_XSD= "http://www.w3.org/2001/XMLSchema";
public string EncodingStyle = "http://www.w3.org/2001/12/soap-encoding";
/// <summary>
/// SOAP版本
......@@ -34,9 +37,9 @@ namespace Mozi.HttpEmbedded.WebService
XmlTextWriter writer = new XmlTextWriter(ms, System.Text.Encoding.UTF8);
writer.WriteStartDocument(true);
writer.WriteStartElement(envelope.Version.Prefix, "Envelope", envelope.Version.Namespace);
writer.WriteAttributeString(envelope.Version.Prefix, "encodingStyle",null,envelope.encodingStyle);
writer.WriteAttributeString("xmlns", "xsi",null,envelope.xsi);
writer.WriteAttributeString("xmlns", "xsd", null,envelope.xsd);
writer.WriteAttributeString(envelope.Version.Prefix, "encodingStyle",null,envelope.EncodingStyle);
writer.WriteAttributeString("xmlns", "xsi",null,envelope.NS_XSI);
writer.WriteAttributeString("xmlns", "xsd", null,envelope.NS_XSD);
//header
if (envelope.Header != null)
{
......@@ -56,6 +59,7 @@ namespace Mozi.HttpEmbedded.WebService
{
writer.WriteElementString(envelope.Body.Prefix, r.Key,null, r.Value);
}
//fault
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndElement();
......@@ -81,9 +85,9 @@ namespace Mozi.HttpEmbedded.WebService
//envelope
var nodeEnvelope = doc.CreateNode(XmlNodeType.Element, envelope.Version.Prefix,"Envelope", envelope.Version.Namespace);
var encodingStyle =doc.CreateAttribute("soap","encodingStyle",envelope.encodingStyle);
var encodingStyle =doc.CreateAttribute("soap","encodingStyle",envelope.EncodingStyle);
var xsi = doc.CreateAttribute("xmlns", "xsi",null);
xsi.Value = envelope.xsi;
xsi.Value = envelope.NS_XSI;
var xsd = doc.CreateAttribute("xsd","xsd", null);
nodeEnvelope.Attributes.Append((XmlAttribute)xsi);
......@@ -134,6 +138,7 @@ namespace Mozi.HttpEmbedded.WebService
}
public class SOAPHeaderChild
{
public string Name { get; set; }
public string actor {get;set;}
public string mustUnderstand { get; set; } //"0"|"1"
public string encodingStyle { get; set; }
......@@ -150,7 +155,11 @@ namespace Mozi.HttpEmbedded.WebService
public class SOAPFault
{
public string faultcode { get; set; }
//VersionMismatch SOAP Envelope 元素的无效命名空间被发现
//MustUnderstand Header 元素的一个直接子元素(带有设置为 "1" 的 mustUnderstand 属性)无法被理解。
//Client 消息被不正确地构成,或包含了不正确的信息。
//Server 服务器有问题,因此无法处理进行下去。
public string faultcode { get; set; }
public string faultstring { get; set; }
public string faultactor { get; set; }
public string detail { get; set; }
......
namespace Mozi.HttpEmbedded.WebService
{
class WSDL
/// <summary>
/// WSDL描述文档
/// </summary>
public class WSDL
{
public string NS_tm = "http://microsoft.com/wsdl/mime/textMatching/";
public string NS_soapenc = "http://schemas.xmlsoap.org/soap/encoding/";
public string NS_mime = "http://schemas.xmlsoap.org/wsdl/mime/";
public string NS_tns = "Service/ServiceCommon/User";
public string NS_soap = "http://schemas.xmlsoap.org/wsdl/soap/";
public string NS_s = "http://www.w3.org/2001/XMLSchema";
public string NS_soap12 = "http://schemas.xmlsoap.org/wsdl/soap12/";
public string NS_http = "http://schemas.xmlsoap.org/wsdl/http/";
public string Prefix = "wsdl";
public string WSDLNamespace = "http://schemas.xmlsoap.org/wsdl/";
public string Namespace = "http://tempurl.org";
public string Documentation { get; set; }
public static string CreateDocument(WSDL document)
{
var text = "";
return text;
}
public class Document
{
public string Name { get; set; }
public string Namespace = "http://schemas.xmlsoap.org/wsdl/";
}
private class Types
{
public string Schema { get; set; }
public string Prefix = "xs";
private class Element
{
public string minOccurs = "";
public string maxOccurs = "";
public string name = "";
public string type = "";
}
}
private class Message
{
public class Part
{
public string Name { get; set; }
public string Element { get; set; }
}
}
private class PortType
{
}
private class ServiceType
{
}
private class Binding
{
}
private class Service
{
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册