从字符串获取价值-Java

时间:2018-12-13 16:48:49

标签: java soap

我从服务器得到响应。

SOAPMessage soapResponse = soapConnection.call(msgRequest, targetEndpoint);

如何获取documentId值?

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Body>
      <retrieveDocumentRequest>
         <documentId>Test</documentId>
      </retrieveDocumentRequest>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

1 个答案:

答案 0 :(得分:0)

这应该可以解决您的问题:

/* start */

begin try
DROP TABLE #SaaS
DROP TABLE #dbNames
DROP TABLE #dbNamesCol1
DROP TABLE #dbNamesCol2
DROP TABLE #dbNamesALL
end try
begin catch
end catch
DECLARE
         @prefix nvarchar(50) =  'WFA'

/**
* Create 5 temp tables for processing
*/
CREATE TABLE #dbNames (dbName NVARCHAR(255)       --will hold the initial database names.
                        , dbName2 NVARCHAR(255))

CREATE TABLE #dbNamesCol1 (db NVARCHAR(255)         --holding table
                            , dbName NVARCHAR(255)) --will remove null values and be the fetch column for @dbName

CREATE TABLE #dbNamesCol2 (db NVARCHAR(255)         --holding table
                            , dbName2 NVARCHAR(255))--will remove null values and be the fetch column for @dbName2

CREATE TABLE #dbNamesAll (db NVARCHAR(255)          --Final table for dbName and dbName2 without NULL values
                          , dbName NVARCHAR(255)    --will join on db
                          , dbName2 NVARCHAR(255))  --Cursor will fetch from this final table

CREATE TABLE #SaaS (dbName NVARCHAR(255)            -- Output Table
                    , varA NVARCHAR(255)
                    , varB NVARCHAR(255))
/**
* Get the databases - all for now
*/
INSERT INTO #dbNames(dbName, dbName2)
SELECT CASE WHEN [name] LIKE '%Reporting' THEN [name] END as dbName
        , CASE WHEN [name] LIKE '%System' THEN [name] END as dbName2
FROM SYS.DATABASES 
WHERE State = 0 

/**
* Create TEMP Table that contains db names from two different
Databases. #dbNamesAll will be a join on db from 
#dbNamesCol1 and #dbNamesCol2 with no null values.
*/
INSERT INTO #dbNamesCol1 (db, dbName)
select REPLACE(dbName,'_Reporting',''), dbName
from #dbNames
WHERE dbName IS NOT NULL

INSERT INTO #dbNamesCol2 (db, dbName2)
select REPLACE(dbName2,'_System',''), dbName2
from #dbNames
WHERE dbName2 IS NOT NULL

INSERT INTO #dbNamesALL (db, dbName, dbName2)
select a.db,
       a.dbName,
       b.dbName2
from #dbNamesCol1 a
LEFT JOIN #dbNamesCol2 b ON b.db = a.db

/**
* A few variables for the Database list cursor
*/
DECLARE @dbName NVARCHAR(255)
      , @dbName2 NVARCHAR(255)
      , @sql NVARCHAR(MAX)

/**
* get the values, only from ACA instances
*/
DECLARE EachDatabase CURSOR FOR 
 SELECT [dbName],
        [dbName2]
 FROM #dbNamesALL

OPEN EachDatabase 
FETCH NEXT FROM EachDatabase INTO @dbName, @dbName2

WHILE @@FETCH_STATUS <> -1
BEGIN

  SET @sql = '
                    DECLARE @varA AS nvarchar(255), @varB AS NVARCHAR(255)

                    SET @varB = (
                                        SELECT customerName
                                        FROM ' + @dbName2 + '.User.SystemSettings
                                        )

                    SET @varA = (
                                    select top 1 varA
                                    from
                                    ' + @dbName + '.eUser.tablecol
                                    WHERE varA >= 1/1/2018
                                    )

                    --REPORT STATUS

                    insert into #SaaS ( DBName
                                        , varA
                                        , varB
                                        )
                    select ''' + REPLACE(@dbName,'Reporting','') + '''
                            , @varA
                            , @varB
            '
  exec(@sql)

  FETCH NEXT FROM EachDatabase INTO @dbName, @dbName2
END

CLOSE EachDatabase
DEALLOCATE EachDatabase
-----------------------------------------End Table for SaaS

SELECT *
from #SaaS
order by dbName

/* end */