我以前是做java EE的 , webservice接触得很少,前段时间去个公司面试,他给我这个题目,我无从下手,题目如下:
SOAP接口编程1、要求:根据以下内容写出web service 接口,以供客户端调用。配合测试,多写个客户端。
2、注意:
(1)不需要考虑“待上传证书”,只需要用一个简单记事本文件代替就行。
(2)“签名算法”,可以不理,只需要用简单字串代替。
(3)“数字签名”,可以不理,只需要用简单字串代替。
1.1 接口协议
本规范定义的接口均采用SOAP协议,版本号为SOAP1.2,在服务端发布WEB服务。
图4.2:注册审核中心 / 网关接口协议栈1.2 接口规范
本接口规范制定了新证书推送接口、上传证书状态接口,规定了其请求消息和响应消息的内容和格式;服务名统一为“ASService”。
1.2.1 新证书推送接口
1.2.1.1 接口描述
本接口应用于WAPI注册审核中心向全国漫游AS推送新签发的省级AS证书,以及WAPI注册审核中心通过省级注册审核网关向本省AS透传推送新签发的本省WAPI证书。
该消息由注册审核中心 / 网关向AS发送。
1.2.1.2 消息名称
UploadCert
1.2.1.3 消息定义
Public int UploadCert(string uploadCertPackage)
1.2.1.4 消息内容
请求:
服务请求包括如下数据:
— 待上传证书;
— 签名算法;
— 数字签名。
响应:
服务响应为具体整数值,分别代表不同情况。具体包括如下值:
— 0:执行服务成功;
— 1:验证请求失败。证书鉴别实体验证来自证书颁发实体的数字签名失败,证书颁发实体应检查后重新发起请求;
— 2:内部处理失败。证书鉴别实体执行具体服务时发生内部错误,证书颁发实体应检查后重新发起请求。
1.2.1.5 数据格式
上传证书请求消息uploadCertPackage的数据格式如下:
<?xml version="1.0" encoding="UTF-8"?>
<UploadCertPackage>
<CertInfo>
<Certificate></Certificate>
</CertInfo>
<Signature>
<SignatureAlgorithm></SignatureAlgorithm>
<SignatureValue></SignatureValue>
</Signature>
</UploadCertPackage>
对上述XML文件中各元素的解释如下:
— Certificate:待上传证书;
— SignatureAlgorithm:签名算法,取值范围为{ ECDSA };
— SignatureValue:对CertInfo元素的数字签名;
1.2.1.6 示例
以下是上传证书接口 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。
POST /asservice/asservice.asmx HTTP/1.1
Host: localhost
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<UploadCert xmlns="http://tempuri.org/">
<uploadCertRequestPackage>string</uploadCertRequestPackage>
</UploadCert>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<UploadCertResponse xmlns="http://tempuri.org/">
<UploadCertResult>int</UploadCertResult>
</UploadCertResponse>
</soap12:Body>
</soap12:Envelope>1.2.2 上传证书状态接口
1.2.2.1 接口描述
本接口应用于WAPI注册审核中心向全国漫游AS推送新废止省级AS证书的消息,以及WAPI注册审核中心通过省级注册审核网关向本省AS透传推送新废止本省WAPI证书的消息。
该消息由注册审核中心 / 网关向AS发送。
1.2.2.2 消息名称
UploadCertStatus
1.2.2.3 消息格式
Public int UploadCertStatus(string uploadCertStatusPackage)
1.2.2.4 消息内容
请求:
服务请求包括如下数据:
— 证书序列号;
— 证书状态;
— 签名算法;
— 数字签名。
响应:
服务响应为具体整数值,分别代表不同情况。具体包括如下值:
— 0:执行服务成功;
— 1:验证请求失败。证书鉴别实体验证来自证书颁发实体的数字签名失败,证书颁发实体应检查后重新发起请求;
— 2:内部处理失败。证书鉴别实体执行具体服务时发生内部错误,证书颁发实体应检查后重新发起请求。
1.2.2.5 数据格式
上传证书请求消息uploadCertStatusPackage的数据格式如下:
<?xml version="1.0" encoding="UTF-8"?>
<UploadCertStatusPackage>
<CertStatusInfo>
<CertSN></CertSN>
<CertStatus></CertStatus>
</CertStatusInfo>
<Signature>
<SignatureAlgorithm></SignatureAlgorithm>
<SignatureValue></SignatureValue>
</Signature>
</UploadCertStatusPackage>
对上述XML文件中各元素的解释如下:
— CertSN:证书序列号;
— CertStatus:证书状态,取值范围为{ revoke | suspend | lift }。其中revoke代表证书撤销,suspend代表证书挂起,lift代表证书解挂;SignatureAlgorithm:签名算法,取值范围为{ ECDSA };
— SignatureValue:对CertInfo元素的数字签名;
1.2.2.6 示例
以下是上传证书状态接口 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。
POST /asservice/asservice.asmx HTTP/1.1
Host: localhost
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<UploadCertStatus xmlns="http://tempuri.org/">
<updateCertStatusRequestPackage>string</updateCertStatusRequestPackage>
</UploadCertStatus>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<UploadCertStatusResponse xmlns="http://tempuri.org/">
<UploadCertStatusResult>int</UploadCertStatusResult>
</UploadCertStatusResponse>
</soap12:Body>
</soap12:Envelope>1.2.3 服务接口WSDL说明
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="http://service.as.wapi.com" xmlns:tns="http://service.as.wapi.com" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.as.wapi.com">
- <xsd:element name="UploadCert">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
- <xsd:element name="UploadCertResponse">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="out" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
- <xsd:element name="UploadCertStatus">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
- <xsd:element name="UploadCertStatusResponse">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="out" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
- <wsdl:message name="UploadCertResponse">
<wsdl:part name="parameters" element="tns:UploadCertResponse" />
</wsdl:message>
- <wsdl:message name="UploadCertStatusResponse">
<wsdl:part name="parameters" element="tns:UploadCertStatusResponse" />
</wsdl:message>
- <wsdl:message name="UploadCertStatusRequest">
<wsdl:part name="parameters" element="tns:UploadCertStatus" />
</wsdl:message>
- <wsdl:message name="UploadCertRequest">
<wsdl:part name="parameters" element="tns:UploadCert" />
</wsdl:message>
- <wsdl:portType name="ASServicePortType">
- <wsdl:operation name="UploadCert">
<wsdl:input name="UploadCertRequest" message="tns:UploadCertRequest" />
<wsdl:output name="UploadCertResponse" message="tns:UploadCertResponse" />
</wsdl:operation>
- <wsdl:operation name="UploadCertStatus">
<wsdl:input name="UploadCertStatusRequest" message="tns:UploadCertStatusRequest" />
<wsdl:output name="UploadCertStatusResponse" message="tns:UploadCertStatusResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="ASServiceHttpBinding" type="tns:ASServicePortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="UploadCert">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="UploadCertRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
- <wsdl:output name="UploadCertResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="UploadCertStatus">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="UploadCertStatusRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
- <wsdl:output name="UploadCertStatusResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="ASService">
-<wsdl:port name="ASServiceHttpPort" binding="tns:ASServiceHttpBinding">
<wsdlsoap:address location="http://211.100.243.205:9999/webservice_as/services/ASService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
SOAP接口编程1、要求:根据以下内容写出web service 接口,以供客户端调用。配合测试,多写个客户端。
2、注意:
(1)不需要考虑“待上传证书”,只需要用一个简单记事本文件代替就行。
(2)“签名算法”,可以不理,只需要用简单字串代替。
(3)“数字签名”,可以不理,只需要用简单字串代替。
1.1 接口协议
本规范定义的接口均采用SOAP协议,版本号为SOAP1.2,在服务端发布WEB服务。
图4.2:注册审核中心 / 网关接口协议栈1.2 接口规范
本接口规范制定了新证书推送接口、上传证书状态接口,规定了其请求消息和响应消息的内容和格式;服务名统一为“ASService”。
1.2.1 新证书推送接口
1.2.1.1 接口描述
本接口应用于WAPI注册审核中心向全国漫游AS推送新签发的省级AS证书,以及WAPI注册审核中心通过省级注册审核网关向本省AS透传推送新签发的本省WAPI证书。
该消息由注册审核中心 / 网关向AS发送。
1.2.1.2 消息名称
UploadCert
1.2.1.3 消息定义
Public int UploadCert(string uploadCertPackage)
1.2.1.4 消息内容
请求:
服务请求包括如下数据:
— 待上传证书;
— 签名算法;
— 数字签名。
响应:
服务响应为具体整数值,分别代表不同情况。具体包括如下值:
— 0:执行服务成功;
— 1:验证请求失败。证书鉴别实体验证来自证书颁发实体的数字签名失败,证书颁发实体应检查后重新发起请求;
— 2:内部处理失败。证书鉴别实体执行具体服务时发生内部错误,证书颁发实体应检查后重新发起请求。
1.2.1.5 数据格式
上传证书请求消息uploadCertPackage的数据格式如下:
<?xml version="1.0" encoding="UTF-8"?>
<UploadCertPackage>
<CertInfo>
<Certificate></Certificate>
</CertInfo>
<Signature>
<SignatureAlgorithm></SignatureAlgorithm>
<SignatureValue></SignatureValue>
</Signature>
</UploadCertPackage>
对上述XML文件中各元素的解释如下:
— Certificate:待上传证书;
— SignatureAlgorithm:签名算法,取值范围为{ ECDSA };
— SignatureValue:对CertInfo元素的数字签名;
1.2.1.6 示例
以下是上传证书接口 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。
POST /asservice/asservice.asmx HTTP/1.1
Host: localhost
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<UploadCert xmlns="http://tempuri.org/">
<uploadCertRequestPackage>string</uploadCertRequestPackage>
</UploadCert>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<UploadCertResponse xmlns="http://tempuri.org/">
<UploadCertResult>int</UploadCertResult>
</UploadCertResponse>
</soap12:Body>
</soap12:Envelope>1.2.2 上传证书状态接口
1.2.2.1 接口描述
本接口应用于WAPI注册审核中心向全国漫游AS推送新废止省级AS证书的消息,以及WAPI注册审核中心通过省级注册审核网关向本省AS透传推送新废止本省WAPI证书的消息。
该消息由注册审核中心 / 网关向AS发送。
1.2.2.2 消息名称
UploadCertStatus
1.2.2.3 消息格式
Public int UploadCertStatus(string uploadCertStatusPackage)
1.2.2.4 消息内容
请求:
服务请求包括如下数据:
— 证书序列号;
— 证书状态;
— 签名算法;
— 数字签名。
响应:
服务响应为具体整数值,分别代表不同情况。具体包括如下值:
— 0:执行服务成功;
— 1:验证请求失败。证书鉴别实体验证来自证书颁发实体的数字签名失败,证书颁发实体应检查后重新发起请求;
— 2:内部处理失败。证书鉴别实体执行具体服务时发生内部错误,证书颁发实体应检查后重新发起请求。
1.2.2.5 数据格式
上传证书请求消息uploadCertStatusPackage的数据格式如下:
<?xml version="1.0" encoding="UTF-8"?>
<UploadCertStatusPackage>
<CertStatusInfo>
<CertSN></CertSN>
<CertStatus></CertStatus>
</CertStatusInfo>
<Signature>
<SignatureAlgorithm></SignatureAlgorithm>
<SignatureValue></SignatureValue>
</Signature>
</UploadCertStatusPackage>
对上述XML文件中各元素的解释如下:
— CertSN:证书序列号;
— CertStatus:证书状态,取值范围为{ revoke | suspend | lift }。其中revoke代表证书撤销,suspend代表证书挂起,lift代表证书解挂;SignatureAlgorithm:签名算法,取值范围为{ ECDSA };
— SignatureValue:对CertInfo元素的数字签名;
1.2.2.6 示例
以下是上传证书状态接口 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。
POST /asservice/asservice.asmx HTTP/1.1
Host: localhost
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<UploadCertStatus xmlns="http://tempuri.org/">
<updateCertStatusRequestPackage>string</updateCertStatusRequestPackage>
</UploadCertStatus>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<UploadCertStatusResponse xmlns="http://tempuri.org/">
<UploadCertStatusResult>int</UploadCertStatusResult>
</UploadCertStatusResponse>
</soap12:Body>
</soap12:Envelope>1.2.3 服务接口WSDL说明
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="http://service.as.wapi.com" xmlns:tns="http://service.as.wapi.com" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.as.wapi.com">
- <xsd:element name="UploadCert">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
- <xsd:element name="UploadCertResponse">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="out" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
- <xsd:element name="UploadCertStatus">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
- <xsd:element name="UploadCertStatusResponse">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="out" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
- <wsdl:message name="UploadCertResponse">
<wsdl:part name="parameters" element="tns:UploadCertResponse" />
</wsdl:message>
- <wsdl:message name="UploadCertStatusResponse">
<wsdl:part name="parameters" element="tns:UploadCertStatusResponse" />
</wsdl:message>
- <wsdl:message name="UploadCertStatusRequest">
<wsdl:part name="parameters" element="tns:UploadCertStatus" />
</wsdl:message>
- <wsdl:message name="UploadCertRequest">
<wsdl:part name="parameters" element="tns:UploadCert" />
</wsdl:message>
- <wsdl:portType name="ASServicePortType">
- <wsdl:operation name="UploadCert">
<wsdl:input name="UploadCertRequest" message="tns:UploadCertRequest" />
<wsdl:output name="UploadCertResponse" message="tns:UploadCertResponse" />
</wsdl:operation>
- <wsdl:operation name="UploadCertStatus">
<wsdl:input name="UploadCertStatusRequest" message="tns:UploadCertStatusRequest" />
<wsdl:output name="UploadCertStatusResponse" message="tns:UploadCertStatusResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="ASServiceHttpBinding" type="tns:ASServicePortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="UploadCert">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="UploadCertRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
- <wsdl:output name="UploadCertResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="UploadCertStatus">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="UploadCertStatusRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
- <wsdl:output name="UploadCertStatusResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="ASService">
-<wsdl:port name="ASServiceHttpPort" binding="tns:ASServiceHttpBinding">
<wsdlsoap:address location="http://211.100.243.205:9999/webservice_as/services/ASService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货