파이썬을 사용하여 서버 측에서 웹 서비스를 생성하는 데 spyne를 사용하여 Excel 클라이언트 (xmla 플러그인)와 통신하고 클라이언트 요청과 일치하는 비누 응답을 생성하는 데 어려움이 있습니다. 의 xmlns 참조 : XSD = "http://www.w3.org/2001/XMLSchema : 는 내가 원하는 것은"XSD "와 루트 태그 스키마에서이 같은 비누 응답 (이다비누 응답 내의 파이썬 xsd
<soap:Envelope xmlns="urn:schemas-microsoft-com:xml-analysis">
<soap:Body>
<DiscoverResponse xmlns="urn:...">
<return>
<root xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"
....>
< xsd:schema targetNamespace="urn:schemas-microsoft-com:xml-analysis:rowset"
xmlns:sql="urn:schemas-microsoft-com:xml-sql">
<xsd:element name="root">
<xsd:complexType>
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element name="row" type="row"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="uuid">
<xsd:restriction base="xsd:string">
<xsd:pattern value="[0-9a-zA-Z]{8}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{12}"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="xmlDocument">
<xsd:sequence>
<xsd:any/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="row">
<xsd:sequence>
<xsd:element sql:field="PropertyName" name="PropertyName" type="xsd:string"/>
<xsd:element sql:field="PropertyDescription" name="PropertyDescription" type="xsd:string" minOccurs="0"/>
<xsd:element sql:field="PropertyType" name="PropertyType" type="xsd:string" minOccurs="0"/>
<xsd:element sql:field="PropertyAccessType" name="PropertyAccessType" type="xsd:string"/>
<xsd:element sql:field="IsRequired" name="IsRequired" type="xsd:boolean" minOccurs="0"/>
<xsd:element sql:field="Value" name="Value" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</root>
</return>
</DiscoverResponse>
</soap:Body>
,691,363 다음 루트에서
(210) 내가 spyne으로 얻은 결과는 모든 시간이 XSD를 포함하지 않습니다 :
models.py 파일 :
<soap11env:Body>
<tns:DiscoverResponse>
<tns:return>
<ns2:root xmlns:ns2="urn:schemas-microsoft-com:xml-analysis:rowset">
<ns3:schema xmlns:ns3="services.models" targetNamespace="urn:schemas-microsoft-com:xml-analysis:rowset"/>
</ns2:root>
</tns:return>
</tns:DiscoverResponse>
여기
내 파이썬 코드
class schema(ComplexModel):
targetNamespace = XmlAttribute(Unicode)
__type_name__ = "schema"
class DiscoverResponse(ComplexModel):
__namespace__ = "urn:schemas-microsoft-com:xml-analysis:rowset"
root = Array(schema.customize(max_occurs='unbounded'))
xmla.py 파일 :
이 문제를 해결하기 위해class xmla_provider(ServiceBase):
@rpc(Unicode,
Restrictionlist,
Propertielist,
_returns=[DiscoverResponse],
_out_variable_names=["return"])
def Discover(ctx, RequestType, Restrictions, Properties):
response = DiscoverResponse()
response.root = schema(targetNamespace="urn:schemas-microsoft-com:xml-analysis:rowset"),
return response
내가 을 추가하려고 __ 네임 스페이스 __ = "
http://www.w3.org/2001/XMLSchema"
클래스 스키마과 내가이 문제를 가지고
경우 child_ns! = self.imports [NS]에서 NS하지 child_ns 및 \ KeyError를 ' http://www.w3.org/2001/XMLSchema'
마음에 오는 좋은 해결책이 아니다있는 다른 솔루션은 모든
01,239,622,349를 반환하여 SOAP 응답 힘 에유니 코드
로 attribut 루트 에 여기 코드는 다음과 같습니다 모델
response.root = "\n < xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns='urn:schemas-microsoft-com:xml-analysis:rowset' ....
xmla.py
있다.평class DiscoverResponse(ComplexModel):
__namespace__ = "urn:schemas-microsoft-com:xml-analysis:rowset"
root = Unicode
내가이 출력 모든 <> 문자로 대체
DEBUG:spyne.protocol.xml:Response <soap11env:Envelope xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="urn:schemas-microsoft-com:xml-analysis">
<soap11env:Body>
<tns:DiscoverResponse>
<tns:return>
<ns0:root xmlns:ns0="urn:schemas-microsoft-com:xml-analysis:rowset">
< xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns='urn:schemas-microsoft-com:xml-analysis:rowset'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:sql='urn:schemas-microsoft-com:xml-sql'
....
/xsd:schema
</ns0:root>
</tns:return>
</tns:DiscoverResponse>
있어 "& LT;" 및 "& gt;" (이것은 좋은 해결책이 아니므로 일반적으로 이름 공간으로 문제를 해결해야 함)문제를 해결하거나 최악의 경우, 이것을 허용하는 비누 라이브러리의 제안을하시기 바랍니다. 응답
당신은 벌거 벗은 모드로 전환하고이 같은AnyXml
을 반환해야
나는 말의 등 모두가 그것을에서 Spyne 코드의 단일 반점없이 Spyne 질문을 물어 당황 해요. 코드를 볼 필요가있어! 오류! 얘들 아, 도와 줘! –
'_returns = AnyXml'을 설정 했습니까? 어떻게 응답을 생성합니까? –
불편을 끼쳐 드려 죄송합니다. 제 질문은 @BurakArslan –