小编ote*_*ezz的帖子

在Go中解析SOAP

我刚刚开始学习Go。我想解析一个SOAP服务。我很难解析XML。这是XML:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

  <SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <wsse:Security soap:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <wsse:UsernameToken>
        <wsse:Username>USERNAME</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">SECRET</wsse:Password>
      </wsse:UsernameToken>
    </wsse:Security>
  </SOAP-ENV:Header>

  <SOAP-ENV:Body xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <OTA_HotelAvailNotifRQ xmlns="http://www.opentravel.org/OTA/2003/05" EchoToken="abc123" Version="1.0" TimeStamp="2005-08-01T09:30:47+08:00">
      <AvailStatusMessages HotelCode="HOTEL">
        <AvailStatusMessage BookingLimit="10">
          <StatusApplicationControl Start="2010-01-01" End="2010-01-14" InvTypeCode="A1K" RatePlanCode="GLD"/>
        </AvailStatusMessage>
      </AvailStatusMessages>
    </OTA_HotelAvailNotifRQ>
  </SOAP-ENV:Body>

</SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)

这是我编写的用于解析XML的代码:

package main

import (
    "fmt"
    "encoding/xml"
)

type Envelope struct {
    XMLName xml.Name
    SOAPENV string   `xml:"xmlns:SOAP-ENV,attr"`
    XSD     string   `xml:"xmlns:xsd,attr"`
    XSI     string   `xml:"xmlns:xsi,attr"`
    SOAPENC string   `xml:"xmlns:SOAP-ENC,attr"`
    NS9132  string   `xml:"xmlns:ns9132,attr"`
    Header  Header   `xml:"SOAP-ENV:Header"`
}

type Header struct {
    XMLName  xml.Name `xml:"SOAP-ENV:Header"`
    Security Security `xml:"wsse:Security"` …
Run Code Online (Sandbox Code Playgroud)

xml soap wsdl go

3
推荐指数
1
解决办法
980
查看次数

Laravel仅数字验证

如何只验证laravel中的数字?我尝试使用数字和数字,但是它接受+和-字符作为我不需要的有效数字/数字。(+123或-123被验证为有效数字)

在laravel上是否有一个仅接受0-9作为有效数字的规则,否则我必须使用正则表达式?

validation laravel

1
推荐指数
1
解决办法
5897
查看次数

标签 统计

go ×1

laravel ×1

soap ×1

validation ×1

wsdl ×1

xml ×1