Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

pedromsr

ASP + Soap 1.2

Recommended Posts

Boa tarde,

Estou a conseguir "consumir" um webservice, mas quero usar Soap12.

Acontece que envio Soap12 e recebo sempre Soap normal

 

Alguém me pode explicar porque ?

Estou a usar uma classe que fiz que me auxilia em muito porque obtenho todos os dados que necessito só com alguns comandos na página principal tipo.

WS.Campo("nomedocampo")

 

 

Envio o XML

<?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>
<PriceQuote xmlns='http://www.jimpisoft.pt/Rentway_Reservations_WS/getPriceQuote'>
<objRequest>
<companyCode>9999</companyCode>
<customerCode>10005</customerCode>
<groupID>01</groupID>
<pickUp>
<Date>2012-03-27 09:00</Date>
<rentalStation>23</rentalStation>
</pickUp>
<dropOff>
<Date>2012-03-29 11:00</Date>
<rentalStation>23</rentalStation>
</dropOff>
</objRequest>
</PriceQuote>
</soap12:Body>
</soap12:Envelope>

 

e recebo

 

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<PriceQuoteResponse xmlns="http://www.jimpisoft.pt/Rentway_Reservations_WS/getPriceQuote">
<PriceQuoteResult>
<rateID>LONGMERE</rateID>
<rate>4403-LONGMERE GOLF TRAVEL</rate>
<dynamicRate>false</dynamicRate>
<nrDays>3</nrDays>
<dayValue>40.65041</dayValue>
<kmsValue>81.30</kmsValue>
<kmsIncluded>false</kmsIncluded>
<previewValue>155.13</previewValue>
<valueWithoutTax>126.12</valueWithoutTax>
<otherTaxValue>0.00</otherTaxValue>
<taxValue>29.01</taxValue>
<taxRate>23.00</taxRate>
<valuePickUp>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="valuePickUp">
<xs:complexType>
<xs:sequence>
<xs:element name="Time" type="xs:string" minOccurs="0" />
<xs:element name="Value" type="xs:decimal" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<valuePickUp diffgr:id="valuePickUp1" msdata:rowOrder="0">
<Time>09:00</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp2" msdata:rowOrder="1">
<Time>09:30</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp3" msdata:rowOrder="2">
<Time>10:00</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp4" msdata:rowOrder="3">
<Time>10:30</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp5" msdata:rowOrder="4">
<Time>11:00</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp6" msdata:rowOrder="5">
<Time>11:30</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp7" msdata:rowOrder="6">
<Time>12:00</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp8" msdata:rowOrder="7">
<Time>12:30</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp9" msdata:rowOrder="8">
<Time>13:00</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp10" msdata:rowOrder="9">
<Time>13:30</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp11" msdata:rowOrder="10">
<Time>14:00</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp12" msdata:rowOrder="11">
<Time>14:30</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp13" msdata:rowOrder="12">
<Time>15:00</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp14" msdata:rowOrder="13">
<Time>15:30</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp15" msdata:rowOrder="14">
<Time>16:00</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp16" msdata:rowOrder="15">
<Time>16:30</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp17" msdata:rowOrder="16">
<Time>17:00</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp18" msdata:rowOrder="17">
<Time>17:30</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp19" msdata:rowOrder="18">
<Time>18:00</Time>
<Value>0.00</Value>
</valuePickUp>
<valuePickUp diffgr:id="valuePickUp20" msdata:rowOrder="19">
<Time>18:30</Time>
<Value>0.00</Value>
</valuePickUp>
</NewDataSet>
</diffgr:diffgram>
</valuePickUp>
<valueDropOff>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="valueDropOff">
<xs:complexType>
<xs:sequence>
<xs:element name="Time" type="xs:string" minOccurs="0" />
<xs:element name="Value" type="xs:decimal" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<valueDropOff diffgr:id="valueDropOff1" msdata:rowOrder="0">
<Time>09:00</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff2" msdata:rowOrder="1">
<Time>09:30</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff3" msdata:rowOrder="2">
<Time>10:00</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff4" msdata:rowOrder="3">
<Time>10:30</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff5" msdata:rowOrder="4">
<Time>11:00</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff6" msdata:rowOrder="5">
<Time>11:30</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff7" msdata:rowOrder="6">
<Time>12:00</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff8" msdata:rowOrder="7">
<Time>12:30</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff9" msdata:rowOrder="8">
<Time>13:00</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff10" msdata:rowOrder="9">
<Time>13:30</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff11" msdata:rowOrder="10">
<Time>14:00</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff12" msdata:rowOrder="11">
<Time>14:30</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff13" msdata:rowOrder="12">
<Time>15:00</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff14" msdata:rowOrder="13">
<Time>15:30</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff15" msdata:rowOrder="14">
<Time>16:00</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff16" msdata:rowOrder="15">
<Time>16:30</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff17" msdata:rowOrder="16">
<Time>17:00</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff18" msdata:rowOrder="17">
<Time>17:30</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff19" msdata:rowOrder="18">
<Time>18:00</Time>
<Value>0.00</Value>
</valueDropOff>
<valueDropOff diffgr:id="valueDropOff20" msdata:rowOrder="19">
<Time>18:30</Time>
<Value>0.00</Value>
</valueDropOff>
</NewDataSet>
</diffgr:diffgram>
</valueDropOff>
<extrasIncluded>PAI</extrasIncluded>
<extrasRequired>ROOF</extrasRequired>
<confidentialRate>false</confidentialRate>
<dayValueWithDiscount>40.65041</dayValueWithDiscount>
<previewValueWithDiscount>155.13</previewValueWithDiscount>
<valueWithDiscountWithoutTax>126.12</valueWithDiscountWithoutTax>
<percentualDiscount>0.00</percentualDiscount>
</PriceQuoteResult>
</PriceQuoteResponse>
</soap:Body>
</soap:Envelope>

Compartilhar este post


Link para o post
Compartilhar em outros sites

eles tem o mesmo tipo de porta WSDL

Compartilhar este post


Link para o post
Compartilhar em outros sites

Isso é que já não sei.

 

No entanto já consegui o que pretendia.

http://bluealliance-pt.w4.makeitsimple.pt/getmultipleprices.asp

 

Agora tenho outro exemplo feito:

 

http://bluealliance-pt.w4.makeitsimple.pt/getgroupDetails.asp

 

Precisava obter um a um os valores:

 

<groupID>01 </groupID>

<group_Name>Group 01</group_Name>

<SIPP>SIP01</SIPP>

etc etc

 

Precisava mostra-los numa página HTML, mas não de forma automática, quer isto dizer

que pretendo depois fazer algo do género de <xsl:value-of select="groupID"/> para colocar os valores na página no sitio pretendido.

 

Já tentei várias coisas mas não consegui, creio que por ser um XM Soap.

No primeiro coloquei <xsl:template match="NewDataSet/MultiplePrices"> e a partir daí consegui pesquisar.

 

No segundo exemplo apenas consegui com um código mostrar tudo automáticamente, mas isto não me resolve o problema pois preciso obter os valores individualmente quando pesquiso por eles para colocar em qualquer parte da página.

 

Se alguém me puder ajudar com o código XSL para o efeito agradeço

Compartilhar este post


Link para o post
Compartilhar em outros sites

faz um loop nele

Compartilhar este post


Link para o post
Compartilhar em outros sites

Nesse acima consegui colocar a funcionar.

 

Agora neste XML não, não consigo pesquisar os valores dentro do GroupDetailsResult

GroupID

group_Name

SIPP

 

Queria que desse para pesquisar pelo valor do elemento, pois só preciso de obter alguns deles.

 

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GroupDetailsResponse xmlns="http://www.jimpisoft.pt/Rentway_Reservations_WS/getGroupDetails">
<GroupDetailsResult>
<groupID>01  </groupID>
<group_Name>Group 01</group_Name>
<SIPP>SIP01</SIPP>
<groupOrderToShow>3</groupOrderToShow>
<suitcases>0</suitcases>
<handbag>0</handbag>
<capacity>0</capacity>
<load>0</load>
<maxLength>0</maxLength>
<minWidth>0</minWidth>
<maxWidth>0</maxWidth>
<height>0</height>
<fuel>DS        </fuel>
<seats>5</seats>
<doors>5</doors>
<category>LIG       </category>
<segment>425</segment>
<chassiType>          </chassiType>
<powerHP>0</powerHP>
<powerKW>0</powerKW>
<co2>100</co2>
<brand>BMW</brand>
<model>530 D   SUB</model>
<details>lkjhsdlkgsdahds hdfahjafdh
df h
dfh adf
hfdhdfhadfj df
jd fjdfjdfjdfakj
fdhdfh  
dfjadf fdjdfjdfjdjf</details>
<imageURL>http://webserverii.jimpisoft.com/Files/ResOnline/group01.jpg</imageURL>
<options>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded" />
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" />
</options>
</GroupDetailsResult>
</GroupDetailsResponse>
</soap:Body>
</soap:Envelope>

Compartilhar este post


Link para o post
Compartilhar em outros sites

ele esta gerando algum erro ?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Não dá erro,

 

simplesmente não sei como efectuar a pesquisa

 

<xsl:template match="GroupDetailsResult"> não funciona

 

Como é que situo o "cursor" para que depois possa mostrar os respectivos elementos e valores que quiser ?

 

é que o math não está a funcionar. qual o match correcto que devo colocar. Creio que o problema é o facto de ser um XML Soap

Compartilhar este post


Link para o post
Compartilhar em outros sites

como esta o XLS ?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Desculpem-me se estiver errado, mas sou novato nisto.

 

 

<xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
   version="2.0">

<xsl:template match="GroupDetailsResult">
A sua pesquisa devolveu <xsl:value-of select="count(GroupDetailsResult)"/> Viaturas
 <center>
<table width="465" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="117" height="22">

<div align="center"><strong>Elemento</strong></div></td>
<td width="125"><div align="center"><strong>Valor</strong></div></td>
</tr>

<xsl:for-each select="brand">
<tr align="center">
<td height="22">Brand<xsl:value-of name ="brand" select="brand"/></td>
<td><xsl:value-of select="normalize-space()"/>
</td>
</tr>
</xsl:for-each>

<xsl:for-each select="model">
<tr align="center">
<td height="22">model<xsl:value-of name ="model" select="model"/></td>
<td><xsl:value-of select="normalize-space()"/>
</td>
</tr>
</xsl:for-each>

<xsl:for-each select="seats">
<tr align="center">
<td height="22">seats<xsl:value-of name ="seats" select="seats"/></td>
<td><xsl:value-of select="normalize-space()"/>
</td>
</tr>
</xsl:for-each>

</table>
</center>
</xsl:template>
</xsl:stylesheet>

Compartilhar este post


Link para o post
Compartilhar em outros sites

O atributo match é usado para associar o modelo com um elemento XML. O atributo match também pode ser utilizado para definir um modelo para todo um ramo do documento XML (isto é, match = "/" define todo o documento).

 

e mude para isso aqui no começo

 

<?xml version=”1.0″ encoding=”UTF-8″?>

<xsl:stylesheet version=”2.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform” xmlns:xs=”http://www.w3.org/2001/XMLSchema” xmlns:fn=”http://www.w3.org/2005/xpath-functions” xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"

>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Não estou a conseguir colocar esse código.

Dá-me o erro

 

msxml6.dll error '80004005'

 

The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document.

 

/getgroupDetails.asp, line 107

Compartilhar este post


Link para o post
Compartilhar em outros sites

<?xml version=”1.0″ encoding=”UTF-8″?>
<xsl:stylesheet version=”2.0″ 
xmlns:xsl=”http://www.w3.org/1999/XSL/Transform” 
xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” 
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
>

 

caso não de certo você deve verificar o valor de retorno quando você carrega o estilo no DOM.

Se for falsa, então verifique o parseError.reason para ver realmente o que é.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Consegui verificar com um validador e acertei o código

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="2.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:xs="http://www.w3.org/2001/XMLSchema"

xmlns:fn="http://www.w3.org/2005/xpath-functions"

xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope"

xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">

 

com sucesso.

 

Acontece que usar

<xsl:template match="/">

 

e

<xsl:for-each select="brand">

Brand<xsl:value-of name ="brand" select="brand"/>

<xsl:value-of select="normalize-space()"/>

</xsl:for-each>

 

não devolve nada.

o caminho para obter o que pretendo deve ser outro concerteza

Compartilhar este post


Link para o post
Compartilhar em outros sites

Creio que descobri uma forma de resolver o problema.

 

 

testei usar o código XML

mas sem as linhas

<GroupDetailsResponse xmlns="http://www.jimpisoft.pt/Rentway_Reservations_WS/getGroupDetails">

e

</GroupDetailsResponse>

 

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">'>http://www.w3.org/2001/XMLSchema">

<soap:Body>

<GroupDetailsResult>

<groupID>01 </groupID>

<group_Name>Group 01</group_Name>

<SIPP>SIP01</SIPP>

<groupOrderToShow>3</groupOrderToShow>

<suitcases>0</suitcases>

<handbag>0</handbag>

<capacity>0</capacity>

<load>0</load>

<maxLength>0</maxLength>

<minWidth>0</minWidth>

<maxWidth>0</maxWidth>

<height>0</height>

<fuel>DS </fuel>

<seats>5</seats>

<doors>5</doors>

<category>LIG </category>

<segment>425</segment>

<chassiType> </chassiType>

<powerHP>0</powerHP>

<powerKW>0</powerKW>

<co2>100</co2>

<brand>BMW</brand>

<model>530 D SUB</model>

<details>lkjhsdlkgsdahds hdfahjafdh

df h

dfh adf

hfdhdfhadfj df

jd fjdfjdfjdfakj

fdhdfh

dfjadf fdjdfjdfjdjf</details>

<imageURL>http://webserverii.jimpisoft.com/Files/ResOnline/group01.jpg</imageURL>

<options>

<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">

<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">

<xs:complexType>

<xs:choice minOccurs="0" maxOccurs="unbounded" />

</xs:complexType>

</xs:element>

</xs:schema>

<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" />

</options>

</GroupDetailsResult>

</soap:Body>

</soap:Envelope>

 

 

no XSL fiz um assim:

 

<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- Edited by XMLSpy® -->

<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">

<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">

 

<xsl:for-each select="//GroupDetailsResult">

<div style="background-color:teal;color:white;padding:4px">

<span style="font-weight:bold"><xsl:value-of select="brand"/></span>

- <xsl:value-of select="model"/>

</div>

<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">

<xsl:value-of select="seats"/> Lugares

,<span style="font-style:italic">

<xsl:value-of select="doors"/> Portas

</span>

</div>

</xsl:for-each>

 

</body>

</html>

 

 

 

Pergunta.

Tem como remover através de XSL as linhas

<GroupDetailsResponse xmlns="http://www.jimpisoft.pt/Rentway_Reservations_WS/getGroupDetails">

e

</GroupDetailsResponse>

 

retornadas pelo WebService ? Com as mesmas o meu XSL não funciona, sem as mesmas funciona :)

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.